Git Product home page Git Product logo

voucherify-ruby-sdk's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voucherify-ruby-sdk's Issues

Ruby 2.7 deprecation warnings: Replace URL.encode

The Voucherify gem gives this warning under Ruby 2.7

lib/voucherify/service/vouchers.rb:19: warning: URI.escape is obsolete

According to the docs URI.encode is an alias for URI.escape, and

This method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case.

Voucherify::Utils.calculate_price does not consider the :amount_limit key

Percent-off vouchers with a cap amount set do not take that cap into consideration when calculating a discount.

From the util code here: https://github.com/voucherifyio/voucherify-ruby-sdk/blob/master/lib/voucherify/utils.rb#L37-L41 It's clear that the discount is a simple function of the percent off times the base price.

Happy to open a PR for this but I'm not sure of all the ways that a cap can come into play. Let me know if you need any more info or a reproduction case to move forward. Thanks!

Add support for "Qualification" actions

The Voucherify documentation describes an endpoint to "Examine Qualification" that is not present in the Ruby SDK.

The Ruby SDK should expose this behavior through a create_qualifications_request method that takes a customer_id and optional context params, returning a list of campaigns said Customer is eligible for.

Extended OrderItem model and List All Promotion Tiers methods

Loyalties Program support

Add support for new methods related to Loyalty Programs.

Validation namespace:

  • Validate Validation Rules: POST /validation-rules/:rule-id/validation - Docs

Rewards namespace:

  • List: GET /rewards - Docs
  • Create: POST /rewards - Docs
  • Get: GET /rewards/:rewardId - Docs
  • Update: PUT /rewards/:rewardId - Docs
  • Delete: DELETE /rewards/:rewardId - Docs
  • List Assignments: GET /rewards/:rewardId/assignments - Docs
  • Create Assignment: POST /rewards/:rewardId/assignments - Docs
  • Update Assignment: PUT /rewards/:rewardId/assignments/:assignmentId - Docs
  • Delete Assignment: DELETE /rewards/:rewardId/assignments/:assignmentId - Docs

Loyalties namespace:

  • List: GET /loyalties - Docs
  • Create: POST /loyalties - Docs
  • Get: GET /loyalties/:campaignId - Docs
  • Update: PUT /loyalties/:campaignId - Docs
  • Delete: DELETE /loyalties/:campaignId - Docs
  • List Reward Assignments: GET /loyalties/:campaignId/rewards - Docs
  • Create Reward Assignment: POST /loyalties/:campaignId/rewards - Docs
  • Update Reward Assignment: PUT /loyalties/:campaignId/rewards/:assignmentId - Docs
  • Delete Reward Assignment: DELETE /loyalties/:campaignId/rewards/:assignmentId - Docs
  • List Earning Rules: GET /loyalties/{campaignId}/earning-rules - Docs
  • Create Earning Rules: POST /loyalties/:campaignId/earning-rules - Docs
  • Update Earning Rules: PUT /loyalties/:campaignId/earning-rules/:earningRuleId - Docs
  • Delete Earning Rules: DELETE /loyalties/:campaignId/earning-rules/:earningRuleId - Docs
  • List Members: GET /loyalties/:campaignId/members - Docs
  • Add Member: POST /loyalties/:campaignId/members - Docs
  • Get Member: GET /loyalties/:campaignId/members/:memberId - Docs
  • Add Points: POST /loyalties/:campaignId/members/:memberId/balance - Docs
  • Redeem Reward: POST /loyalties/:campaignId/members/:memberId/redemption - Docs

Support blank API response in exception handling

I've received a few errors originating from this line https://github.com/voucherifyio/voucherify-ruby-sdk/blob/master/lib/voucherify/client.rb#L145

unexpected token at ''
/usr/local/bundle/gems/json-2.6.3/lib/json/common.rb:216:in `parse',
/usr/local/bundle/gems/json-2.6.3/lib/json/common.rb:216:in `parse',
/usr/local/bundle/gems/voucherify-4.1.0/lib/voucherify/client.rb:145:in `initialize',
/usr/local/bundle/gems/voucherify-4.1.0/lib/voucherify/client.rb:93:in `new',
...

It appears that the error response is empty and the client cannot handle empty error responses. I've not be able to discover what is causing the empty error response. I can't find the request in the Voucherify API audit logs, so I suspect the request doesn't reach Voucherify. But it will help if the client can gracefully handle errors with empty responses.

Feature: Retry with exponential backoff

At the moment we're wrapping around the outside of the Voucherify SDK to rescue + inspect the errors it raises to implement our own retry mechanism to deal with the odd timeout and very occasionally an odd network error or two.

Are there any plans to build a retry mechanism into the Ruby SDK ร  la Stripe's Ruby client?

See here for Stripe's implementation: https://github.com/stripe/stripe-ruby/blob/master/lib/stripe/stripe_client.rb#L451

If we were to put aside the time to move our retry mechanism into this gem would @voucherifyio be open to merging this in rather than us maintaining our own fork?

Utils Method for signature verification

Maybe we shall consider adding utils method for handling signature verification.

require 'openssl'

  def verify_webhook
    calculated_hmac = OpenSSL::HMAC.hexdigest('sha256', SECRET, request.body.read)
    ActiveSupport::SecurityUtils.secure_compare(calculated_hmac, request.headers["X-Voucherify-Signature"])
  end

Cancelling an Order via Ruby

I'm currently unable to cancel an order using the Ruby client. Cancelling orders using Curl works as expected, but making the request with the same request body using Ruby client doesn't work. Here are a couple of log ids

  • log_0d446e83efc39dca2f (using Curl)
  • log_0d44702edb9151d061 (using the Ruby client)

Since the requests are the same, I suspect the API is responding differently based on the user-agent or channel headers?

User customizable timeout for RestClient requests

We would like to reduce the max timeout from the default 60 seconds but the RestClient configuration doesn't seem to be accessible without monkey patching the client.

Would it be possible to poke through the timeout as a top-level config?

Thanks!

Consents API support

Consents namespace:

  • List Consents: GET /consents - Docs
  • List Consents (Client): GET /consents - Docs

Customers namespace:

  • Update Customer's Consents: PUT /customers/{id}/consents - Docs
  • Update Customer's Consents (Client): PUT /customers/{id}/consents - Docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.