voucherifyio / voucherify-ruby-sdk Goto Github PK
View Code? Open in Web Editor NEWRuby SDK for Voucherify - coupons, vouchers, promo codes
Home Page: http://www.voucherify.io
License: MIT License
Ruby SDK for Voucherify - coupons, vouchers, promo codes
Home Page: http://www.voucherify.io
License: MIT License
Drop API version support for other versions than 2018-08-01 and latest
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.
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!
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.
Make sure that the following methods are provided:
Make sure that the following methods can work with extended Order Item model:
Order; https://docs.voucherify.io/v2018-08-01/reference#the-order-object
Order Items; https://docs.voucherify.io/v2018-08-01/reference#the-order-item-object\
Create Order; https://docs.voucherify.io/v2018-08-01/reference#create-order
Update Order; https://docs.voucherify.io/v2018-08-01/reference#update-order
Validate Voucher; https://docs.voucherify.io/v2018-08-01/reference#validate-voucher
Validate Voucher (client side); https://docs.voucherify.io/v2018-08-01/reference#vouchers-validate
Validate Promotions; https://docs.voucherify.io/v2018-08-01/reference#validate-promotions-1
Redeem Voucher; https://docs.voucherify.io/v2018-08-01/reference#redeem-voucher
Redeem Voucher (client side); https://docs.voucherify.io/v2018-08-01/reference#redeem-voucher-client-side
Redeem Promotion; https://docs.voucherify.io/v2018-08-01/reference#redeem-promotion
Close the issue if no operation is needed or provide a solution with next release.
Add support for new methods related to Loyalty Programs.
Validation namespace:
/validation-rules/:rule-id/validation
- DocsRewards namespace:
/rewards
- Docs/rewards
- Docs/rewards/:rewardId
- Docs/rewards/:rewardId
- Docs/rewards/:rewardId
- Docs/rewards/:rewardId/assignments
- Docs/rewards/:rewardId/assignments
- Docs/rewards/:rewardId/assignments/:assignmentId
- Docs/rewards/:rewardId/assignments/:assignmentId
- DocsLoyalties namespace:
/loyalties
- Docs/loyalties
- Docs/loyalties/:campaignId
- Docs/loyalties/:campaignId
- Docs/loyalties/:campaignId
- Docs/loyalties/:campaignId/rewards
- Docs/loyalties/:campaignId/rewards
- Docs/loyalties/:campaignId/rewards/:assignmentId
- Docs/loyalties/:campaignId/rewards/:assignmentId
- Docs/loyalties/{campaignId}/earning-rules
- Docs/loyalties/:campaignId/earning-rules
- Docs/loyalties/:campaignId/earning-rules/:earningRuleId
- Docs/loyalties/:campaignId/earning-rules/:earningRuleId
- Docs/loyalties/:campaignId/members
- Docs/loyalties/:campaignId/members
- Docs/loyalties/:campaignId/members/:memberId
- Docs/loyalties/:campaignId/members/:memberId/balance
- Docs/loyalties/:campaignId/members/:memberId/redemption
- DocsAdd support for following API Endpoint:
https://docs.voucherify.io/reference#get-member-activities
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.
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?
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
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
Since the requests are the same, I suspect the API is responding differently based on the user-agent or channel headers?
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!
Hi,
Can't see utils functions like in that implementations:
https://github.com/rspective/voucherify.js/blob/master/lib/voucherify.js#L210
or
https://github.com/rspective/voucherify-nodejs-sdk/blob/master/utils.js
do I need to implement it for my ruby backend client?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.