Giter VIP home page Giter VIP logo

voucherify-ios-sdk's Introduction

Official Voucherify SDK for Swift

Setup | Contributing | Changelog | License |

API: Validations | Redemptions | Voucher Listing | Promotions

Setup

The Voucherify Swift SDK requires Swift 5.1

Using CocoaPods:
pod "VoucherifySwiftSdk"

Configuration

The VoucherifyClient manages your interaction with the Voucherify API.

VoucherifyClient(
    clientId: YOUR-PUBLIC-CLIENT-APPLICATION-ID,
    clientToken: YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN)

We are tracking users which are validating vouchers with those who consume them, by a tracking_id. By that we are setting up an identity for the user. If you want to provide your custom value for tracking_id, you have to do it when creating VoucherifyClient:

VoucherifyClient(
    clientId: YOUR-PUBLIC-CLIENT-APPLICATION-ID,
    clientToken: YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN,
    origin: YOUR_ORIGIN,
    trackingId: YOUR_TRACKING_ID,
    configuration: Configuration)

API Endpoint

Optionally, you can specify server configuration option if you want to use Voucherify running in a specific region.

let configuration = Configuration()
configuration.server = "https://<region>.api.voucherify.io"

VoucherifyClient(
    clientId: YOUR-PUBLIC-CLIENT-APPLICATION-ID,
    clientToken: YOUR-PUBLIC-CLIENT-APPLICATION-TOKEN,
    origin: YOUR_ORIGIN,
    trackingId: YOUR_TRACKING_ID,
    configuration: configuration)

API

Voucher listing

    client.vouchers.list(customer: String?,
                      	 completion: @escaping (_ response: Result<VoucherList>) -> Void

Validations

    client.validations.validateVoucher(code: String,
                                       amount: Int? = nil,
                                       completion: (_ response: Result<VoucherResponse>) -> Void)
    client.validations.validateVoucher(code: String,
                                       amount: Int? = nil,
                                       orderItems: [OrderItem],
                                       completion: (_ response: Result<VoucherResponse>) -> Void)
    client.validations.validatePromotion(validationContext: promotionValidationContext,
                                         completion: (_ response: Result<PromotionValidationResponse>) -> Void)

Redemptions

    client.redeemptions.redeem(code: String,
                               redeemContext: VoucherRedemptionContext? = nil,
                               completion: (_ response: Result<VoucherRedemptionResult>) -> Void)
    client.redeemptions.redeem(promotionTierId: String,
                               redeemContext: PromotionRedemptionContext,
                               completion: @escaping (Result<PromotionTierRedemptionResult>) -> Void)

Promotions

    client.promotions.list(isAvailable: Bool = true,
                           limit: Int = 100,
                           page: Int = 1,
                           completion: @escaping (Result<PromotionTierPage>) -> Void)

Contributing

Bug reports and pull requests are welcome through GitHub Issues.

Changelog

  • 2020-11-28 - 4.1.0 - Extend VoucherResponse by campaign and campaignId field, update dependencies, Swift 5.3
  • 2019-11-10 - 4.0.0 - Swift 5.1 and increased ios minimum deployment target to 10
  • 2019-02-18 - 3.3.0 - Add API method to list promotion tiers
  • 2019-01-27 - 3.2.0 - Add API method to list vouchers
  • 2019-01-02 - 3.1.0 - Add API methods to validate and redeem a promotion
  • 2018-12-15 - 3.0.0 - Client's API unification. Information about breaking changes can be find here: https://github.com/voucherifyio/voucherify-ios-sdk/wiki/Voucherify-3.0.0-Migration-Guide
  • 2018-12-04 - 2.0.0 - Swift 4.2
  • 2018-09-29 - 1.4.0 - Change minimum target version to 9.0 and update external dependency to the latest version
  • 2017-03-17 - 1.3.0 - Improve error handling
  • 2017-03-17 - 1.2.0 - Fix OrderItem mappings
  • 2017-03-16 - 1.1.0 - Update Order and OrderItem model
  • 2017-01-12 - 1.0.0 - Unify API with other voucherify SDKs
  • 2016-09-15 - 0.4.0 - Redeem a voucher
  • 2016-08-08 - 0.3.0 - Validate voucher with validation rules concerning products or variants (SKUs)
  • 2016-07-22 - 0.2.0 - Validate gift voucher
  • 2016-07-08 - 0.1.0 - Validate voucher by its code

License

MIT. See the LICENSE file for details.

voucherify-ios-sdk's People

Contributors

awilczek avatar polok avatar sedzia avatar tpindel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

voucherify-ios-sdk's Issues

Alamofire 5.2

It would be cool if you could move to alamofire 5.2, as you are blocking me from using the new version ;-)

Kind Regards
Graham

Custom Validation Errors support

Make sure that developer using this SDK is able to correctly retrieve custom error message coming from validation / redemption methods. Custom error message is a part of error property.
Update README file to include information about custom error messages.

More information can be found in documentation under following links:
https://docs.voucherify.io/reference#section-custom-error-messages-with-validation-rules
https://docs.voucherify.io/reference#the-validation-rule-object
https://docs.voucherify.io/reference#create-validation-rules

Problem with weak reference

Dear Voucherifiers,

I hit a problem when upgrading the most recent Swift SDK. With the old one it works fine.

When I validate vouchers with the new SDK it works fine, but when I try to redeem afterwards I hit an issues in VoucherifyRedemption.swift, in the function redeem.

In your code the [weak self] (response) causes the "guard let strongSelf = self else {return} to always return.

When I remove the weak it works perfectly.

This seems to be a common problem when using Alamofire:
https://stackoverflow.com/questions/49004074/weak-self-always-nil-in-asynchronous-closure-alamofire?rq=1

Thanks for your help.

Kind Regards
Graham

Extended OrderItem model and List All Promotion Tiers methods

Loyalty Programs

Redemption:

  • Redeem Voucher (client), added reward property Docs

Events:

  • Track Event (client), added loyalty property Docs

Configure your website URL in Client-side Settings.

I am using ApplicationSandboxAppID and ApplicationSandboxAppSecret but while verifying coupon it will gives me error like below.

FAILURE: GeneralError(code: Optional(403), details: Optional("Origin 'http://voucherify-swift\' is not trusted. Configure 'Your website URL' in Client-side Settings."), message: Optional("Invalid origin"))

How can I Fix this error?

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.