VoucherifySwiftSdk 4.1.0

VoucherifySwiftSdk 4.1.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最后发布2020年10月
SPM支持 SPM

Marcin PolakMarcin Polak维护。



 
依赖
Alamofire~> 5.3.0
ObjectMapper~> 4.2.0
 

官方Voucherify Swift SDK

设置 | 贡献 | 更改日志 | 许可 |

API: 验证 | 兑换 | 代金券列表 | 促销

设置

Voucherify Swift SDK 需要 Swift 5.1

使用 CocoaPods
pod "VoucherifySwiftSdk"

配置

VoucherifyClient 用于管理您与 Voucherify API 的交互。

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

我们通过tracking_id追踪使用验证券的用户和消费用户,从而为用户设置一个身份。如果您想为tracking_id提供自定义值,您需要在创建VoucherifyClient时进行此操作。

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

API端点

如果希望使用特定区域的Voucherify运行,您可以可选地指定server配置选项。

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

券列表

列出券

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

校验

验证券

    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)

兑换券

兑换券

    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)

促销活动

列出促销等级

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

贡献

欢迎通过 GitHub Issues 提交错误汇报和拉取请求。

变更日志

  • 2020-11-28 - 4.1.0 - 扩展VoucherResponse,增加campaigncampaignId字段,更新依赖,Swift 5.3
  • 2019-11-10 - 4.0.0 - Swift 5.1,并将iOS最小部署目标提升至10
  • 2019-02-18 - 3.3.0 - 添加列出促销层级API方法
  • 2019-01-27 - 3.2.0 - 添加列出代金券API方法
  • 2019-01-02 - 3.1.0 - 添加验证和兑换促销的API方法
  • 2018-12-15 - 3.0.0 - 客户端API统一。有关破坏性更改的信息请参阅:[https://github.com/voucherifyio/voucherify-ios-sdk/wiki/Voucherify-3.0.0-Migration-Guide](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 - 将最小目标版本更改为9.0,并更新外部依赖到最新版本
  • 2017-03-17 - 1.3.0 - 改进错误处理
  • 2017-03-17 - 1.2.0 - 修复OrderItem映射
  • 2017-03-16 - 1.1.0 - 更新Order和OrderItem模型
  • 2017-01-12 - 1.0.0 - 统一API与其他voucherify SDK
  • 2016-09-15 - 0.4.0 - 兑换代金券
  • 2016-08-08 - 0.3.0 - 使用关于产品或变体(SKUs)的验证规则验证代金券
  • 2016-07-22 - 0.2.0 - 验证礼品券
  • 2016-07-08 - 0.1.0 - 根据代码验证代金券

许可证

MIT。有关详细信息,请参阅LICENSE文件。