Paybook 1.2.0

Paybook 1.2.0

测试已测试
Lang语言 SwiftSwift
许可 MIT
发布上次发布2016年10月
SwiftSwift 版本2.3
SPM支持 SPM

Gabriel Villarreal 维护。



Paybook 1.2.0

  • Paybook Inc.

Paybook iOS 库 V1.2.0

这是 Paybook 的 iOS 库。通过这个库,您可以快速简单地通过其类和方法实现 Paybook 的 API REST。

要求

  1. Xcode 7.3+
  2. CocoaPods 依赖管理器 ($ gem install cocoapods)

安装

要使用 CocoaPods 在 Xcode 中集成 Paybook,我们首先要安装 Paybook 库,为此,我们需要在终端中导航到我们的项目目录,然后执行以下命令以创建我们的 pod 文件

$ pod init

*重要: 执行上述命令需要您在您的机器上已安装 Cocoapods。

下一步是编辑我们的 pod file 以添加我们的依赖项,使用以下命令在 Xcode 中打开您的 pod file

$ open -a Xcode Podfile

将 pod file 的内容替换为以下代码

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'YOUR_PROJECT_NAME' do
use_frameworks!
pod 'Paybook', '~> 1.2.0'
end

重要: 为了支持不同的 Swift 版本,请检查您应在 Pod File 中添加的 Paybook 版本

  • Swift 2.2- -> Paybook 1.1.1
  • Swift 2.3 -> Paybook 1.2.0

快速入门

在查看文档之前,你可以查看我们的教程

提醒

  • 您可以在这里查看 API REST 文档
  • 您可以在这里查看我们为您提供的一切资源

文档

每个方法都按照以下结构进行文档化

method_type returned_value_type x = class_or_instance.get(attr1:attr1_type,...,attrn:attrN_type)
  1. method_type: 指示方法是否是静态的,如果不是,则表示该方法为实例方法,或者是一个构造函数。
  2. returned_value_type: 指示方法返回的数据类型
  3. x: 是方法返回值的表示
  4. 类或实例:包含要执行方法的类或类的实例
  5. attrX:是属性X的名称
  6. attrX_type:是属性X的数据类型

重要:所有方法都需要通过id_user或会话进行身份验证,并返回通过completionHandler函数返回的类型数据,该函数在请求成功时返回数据类型,失败时返回错误。例如:

Account.get([mySession], id_user: nil, completionHandler: {
    response, error in
    print("\(response), \(error)")
})

账户

类属性结构

Account
+ str id_account
+ str id_external
+ str id_user
+ str id_credential
+ str id_site
+ str id_site_organization
+ str name
+ str number
+ float balance
+ str site
+ int dt_refresh

类方法的描述

操作 REST API ENDPOINT 库方法
请求用户账户 GET https://sync.paybook.com/v1/accounts static NSArray [Account] = Account.get(session:Session?,id_user:String?,completionHandler:(([Account]?, PaybookError?)->())?)

附件

类属性结构

附件
+ str id_account
+ str id_external
+ str id_user
+ str id_attachment_type
+ str id_transaction
+ str file
+ str extra
+ str url
+ int dt_refresh

类方法的描述

操作 REST API ENDPOINT 库方法
请求附件 GET https://sync.paybook.com/v1/attachments
GET https://sync.paybook.com/v1/attachments/:id_attachment
GET https://sync.paybook.com/v1/attachments/:id_attachment/extra
static NSArray [Attachment] = Attachment.get(session:Session?,id_user:String?,completionHandler:(([Attachments]?,PaybookError?)->())?)
请求附件的数量 GET https://sync.paybook.com/v1/attachments/counts static int attachments_count = Attachment.get_count(session:Session?,id_user:String?,completionHandler:((Int?,PaybookError?)->())?)

目录

类结构

Account_type Attachment_type Country
+ str id_account_type
+ str name
+ str id_attachment_type
+ str name
+ str id_country
+ str name
+ str code
Site Credential_structure Site_organization
+ str id_site
+ str id_site_organization
+ str id_site_organization_type
+ str name
+ list credentials
+ str name
+ str type
+ str label
+ bool required
+ str username
+ str id_site_organization
+ str id_site_organization_type
+ str id_country
+ str name
+ str avatar
+ str small_cover
+ str cover

类方法的描述

操作 REST API ENDPOINT 库方法
请求账户类型 GET https://sync.paybook.com/v1/catalogues/account_types static NSArray [Account_type] = Catalogues.get_account_types(session:Session?,id_user:String?,completionHandler:(([Account_type]?, PaybookError?]->())?)
请求附件类型 GET https://sync.paybook.com/v1/catalogues/attachment_types static NSArray [Attachment_type] = Catalogues.get_attachment_types(session:Session?,id_user:String?,completionHandler:(([Attachment_type]?,PaybookError?]->())?)
请求可用的国家 GET https://sync.paybook.com/v1/catalogues/countries static NSArray [Country] = Catalogues.get_countries(session:Session?,id_user:String?,completionHandler:(([Country]?,PaybookError?]->())?)
请求可用的站点 GET https://sync.paybook.com/v1/catalogues/sites static NSArray [Site] = Catalogues.get_sites(session:Session?,id_user:String?,completionHandler:(([Site]?,PaybookError?]->())?)
请求站点组织 GET https://sync.paybook.com/v1/catalogues/site_organizations static NSArray [Site_organization] = Catalogues.get_site_organizations(session:Session?,id_user:String?,completionHandler:(([Site_organization]?,PaybookError?]->())?)

凭证

类属性结构

凭证
+ str id_site
+ str id_credential
+ str username
+ str id_site_organization
+ str id_site_organization_type
+ str ws
+ str status
+ str twofa

类方法的描述

操作 REST API ENDPOINT 库方法
创建或更新凭证 POST https://sync.paybook.com/v1/credentials Credentials credentials = Credential(session:Session?,id_user:String?,id_site:String,credentials:NSDictionary,completionHandler:((Credentials?,PaybookError?)->())?)
删除凭证 DELETE https://sync.paybook.com/v1/credentials/:id_credential static Bool deleted = Credentials.delete(session:Session?,id_user:String?,id_credential:String,completionHandler:((Bool?,PaybookError?)->())?)
请求状态 GET status_url list [NSDictionary] = credentials.get_status(session:Session?,id_user:String?,completionHandler:(([NSDictionary]?,PaybookError?)->())?)
设置双因素认证 POST twofa_url bool twofa_set = credentials.set_twofa(session:Session?,id_user:String?,params:NSDictionary,completionHandler:((Bool?,PaybookError?)->())?)
请求注册凭证 GET https://sync.paybook.com/v1/credentials static list [Credentials] = Credentials.get(session:Session?,id_user:String?,completionHandler:(([Credentials]?,PaybookError?)->())?)

会话

类属性结构

会话
+ 用户 user
+ 字符串 token

类方法的描述

操作 REST API ENDPOINT 库方法
创建会话 POST https://sync.paybook.com/v1/sessions Session session = Session(id_user:String,completionHandler:((Session?,PaybookError?)->())?)
验证会话 GET https://sync.paybook.com/v1/sessions/:token/verify NSDictionary verified = session.verify(completionHandler:((NSDictionary?, PaybookError?)->())?)
删除会话 DELETE https://sync.paybook.com/v1/sessions/:token static Bool deleted = Session.delete(token:String,completionHandler:((Bool?,PaybookError?)->())?)

交易

类属性结构

交易
+ str id_transaction
+ str id_user
+ str id_external
+ str id_site
+ str id_site_organization
+ str id_site_organization_type
+ str id_account
+ str id_account_type
+ 字符串 is_disable
+ 字符串 description
+ 浮点数 amount
+ 整数 dt_transaction
+ int dt_refresh

类方法的描述

操作 REST API ENDPOINT 库方法
请求交易数量 GET https://sync.paybook.com/v1/transactions/count static int transactions_count = Transaction.get_count(session :Session,id_user:String?,completionHandler:((Int?, PaybookError?)->())?)
请求交易 GET https://sync.paybook.com/v1/transactions static NSArray [Transaction] = Transaction.get(session:Session?,id_user:String?,completionHandler:(([Transaction]?,PaybookError?)->())?)

用户

类属性结构

用户
+ str name
+ str id_user
+ str id_external
+ 整数 dt_create
+ 整数 dt_modify

类方法的描述

操作 REST API ENDPOINT 库方法
创建用户 POST https://sync.paybook.com/v1/users User user = User(username:String,completionHandler:((User?,PaybookError?)->())?)
删除用户 DELETE https://sync.paybook.com/v1/users static Bool deleted = User.delete(id_user:String,completionHandler: ((Bool?, PaybookError?)->())?)
获取用户列表 GET https://sync.paybook.com/v1/users static NSArray [User] = User.get(completionHandler:(([User]?,PaybookError?)->())?)