Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/Pokepay/BankAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

public struct BankAPI {
public struct Account {}
public struct Bank {}
public struct Bill {}
public struct Campaign {}
public struct Cashtray {}
public struct Check {}
public struct Coupon {}
public struct Cpm {}
public struct CpmToken {}
public struct CreditCard {}
public struct Merchants {}
public struct PrivateMoney {}
public struct Terminal {}
public struct Transaction {}
Expand Down
11 changes: 7 additions & 4 deletions Sources/Pokepay/BankAPI/Account/CreateAccount.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct Create: BankRequest {
struct CreateAccount: BankRequest {
public let name: String?
public let privateMoneyId: String
public let externalId: String?

public typealias Response = Account
public typealias Response = AccountDetail

public init(name: String? = nil, privateMoneyId: String, externalId: String? = nil) {
self.name = name
Expand All @@ -24,15 +25,17 @@ public extension BankAPI.Account {

public var parameters: Any? {
var dict: [String: Any] = [:]

if name != nil {
dict["name"] = name
}

dict["private_money_id"] = privateMoneyId

if externalId != nil {
dict["external_id"] = externalId
}

return dict
}
}
Expand Down
70 changes: 26 additions & 44 deletions Sources/Pokepay/BankAPI/Account/CreateAccountCpmToken.swift
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct CreateAccountCpmToken: BankRequest {

public enum Scope: Int {
case PAYMENT = 1
case TOPUP = 2
case BOTH = 3
}

public let accountId: String
public let scopes: Int
public let scopes: [String]?
public let expiresIn: Int?
public let metadata: [String:String]?
public let metadata: String?
public let keepAlive: Bool?
public let isShortToken: Bool?
public let accountId: Uuid

public typealias Response = AccountCpmToken
public typealias Response = CpmToken

public init(accountId: String, scopes: Scope = .PAYMENT, expiresIn: Int? = nil, metadata: [String:String]? = nil) {
self.accountId = accountId
self.scopes = scopes.rawValue
self.expiresIn = expiresIn
self.metadata = metadata
}

public init(accountId:String, scopes:Int,expiresIn: Int? = nil,metadata: [String:String]? = nil){
self.accountId = accountId
public init(scopes: [String]? = nil, expiresIn: Int? = nil, metadata: String? = nil, keepAlive: Bool? = nil, isShortToken: Bool? = nil, accountId: Uuid) {
self.scopes = scopes
self.expiresIn = expiresIn
self.metadata = metadata
self.keepAlive = keepAlive
self.isShortToken = isShortToken
self.accountId = accountId
}

public var method: HTTPMethod {
Expand All @@ -40,37 +31,28 @@ public extension BankAPI.Account {

public var parameters: Any? {
var dict: [String: Any] = [:]
var scopesArr: [String] = []
if (scopes & Scope.PAYMENT.rawValue) != 0 {
scopesArr.append("payment")
}
if (scopes & Scope.TOPUP.rawValue) != 0 {
scopesArr.append("topup")

if scopes != nil {
dict["scopes"] = scopes
}
dict["scopes"] = scopesArr

if expiresIn != nil {
dict["expires_in"] = expiresIn
}

if metadata != nil {

dict["metadata"] = self.toJsonString(metadata:metadata!)
dict["metadata"] = metadata
}
return dict
}

private func toJsonString(metadata:[String:String]) -> String{
var jsonString = "{"
for (key, value) in metadata {
jsonString.append("\"")
jsonString.append(key)
jsonString.append("\":\"")
jsonString.append(value)
jsonString.append("\"")
jsonString.append(",")

if keepAlive != nil {
dict["keep_alive"] = keepAlive
}

if isShortToken != nil {
dict["is_short_token"] = isShortToken
}
jsonString.removeLast()
jsonString.append("}")
return jsonString

return dict
}
}
}
19 changes: 13 additions & 6 deletions Sources/Pokepay/BankAPI/Account/GetAccount.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct Get: BankRequest {
public let id: String
struct GetAccount: BankRequest {
public let accountId: Uuid

public typealias Response = Account
public typealias Response = AccountDetail

public init(id: String) {
self.id = id
public init(accountId: Uuid) {
self.accountId = accountId
}

public var method: HTTPMethod {
return .get
}

public var path: String {
return "/accounts/\(id)"
return "/accounts/\(accountId)"
}

public var parameters: Any? {
var dict: [String: Any] = [:]

return dict
}
}
}
50 changes: 50 additions & 0 deletions Sources/Pokepay/BankAPI/Account/GetAccountBalances.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct GetAccountBalances: BankRequest {
public let accountId: String
public let before: String?
public let after: String?
public let perPage: Int?
public let expired: BooleanString

public typealias Response = PaginatedAccountBalances

public init(accountId: String, before: String? = nil, after: String? = nil, perPage: Int? = nil, expired: BooleanString) {
self.accountId = accountId
self.before = before
self.after = after
self.perPage = perPage
self.expired = expired
}

public var method: HTTPMethod {
return .get
}

public var path: String {
return "/accounts/\(accountId)/balances"
}

public var parameters: Any? {
var dict: [String: Any] = [:]

if before != nil {
dict["before"] = before
}

if after != nil {
dict["after"] = after
}

if perPage != nil {
dict["per_page"] = perPage
}

dict["expired"] = expired

return dict
}
}
}
13 changes: 10 additions & 3 deletions Sources/Pokepay/BankAPI/Account/GetAccountCouponDetail.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct GetCouponDetail:BankRequest {
struct GetAccountCouponDetail: BankRequest {
public let accountId: String
public let couponId:String
public let couponId: String

public typealias Response = CouponDetail

public init(accountId: String, couponId:String) {
public init(accountId: String, couponId: String) {
self.accountId = accountId
self.couponId = couponId
}
Expand All @@ -19,5 +20,11 @@ public extension BankAPI.Account {
public var path: String {
return "/accounts/\(accountId)/coupons/\(couponId)"
}

public var parameters: Any? {
var dict: [String: Any] = [:]

return dict
}
}
}
20 changes: 12 additions & 8 deletions Sources/Pokepay/BankAPI/Account/GetAccountCoupons.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct GetAccountCoupons: BankRequest {
public let accountId: String
public let isAvailable:Bool?
public let accountId: Uuid
public let isAvailable: BooleanString
public let before: String?
public let after: String?
public let perPage: Int32?
public let perPage: Int?

public typealias Response = PaginatedCoupons
public typealias Response = PaginatedAccountCoupons

public init(accountId: String,isAvailable:Bool? = nil , before: String? = nil, after: String? = nil, perPage: Int32? = nil) {
public init(accountId: Uuid, isAvailable: BooleanString, before: String? = nil, after: String? = nil, perPage: Int? = nil) {
self.accountId = accountId
self.isAvailable = isAvailable
self.before = before
Expand All @@ -28,18 +29,21 @@ public extension BankAPI.Account {

public var parameters: Any? {
var dict: [String: Any] = [:]
if isAvailable != nil {
dict["is_available"] = isAvailable
}

dict["is_available"] = isAvailable

if before != nil {
dict["before"] = before
}

if after != nil {
dict["after"] = after
}

if perPage != nil {
dict["per_page"] = perPage
}

return dict
}
}
Expand Down
19 changes: 12 additions & 7 deletions Sources/Pokepay/BankAPI/Account/GetAccountTransactions.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// DO NOT EDIT: File is generated by code generator.
import APIKit

public extension BankAPI.Account {
struct GetTransactions: BankRequest {
public let id: String
struct GetAccountTransactions: BankRequest {
public let accountId: Uuid
public let before: String?
public let after: String?
public let perPage: Int32?
public let perPage: Int?

public typealias Response = PaginatedTransactions
public typealias Response = PaginatedAccountTransactions

public init(id: String, before: String? = nil, after: String? = nil, perPage: Int32? = nil) {
self.id = id
public init(accountId: Uuid, before: String? = nil, after: String? = nil, perPage: Int? = nil) {
self.accountId = accountId
self.before = before
self.after = after
self.perPage = perPage
Expand All @@ -21,20 +22,24 @@ public extension BankAPI.Account {
}

public var path: String {
return "/accounts/\(id)/transactions"
return "/accounts/\(accountId)/transactions"
}

public var parameters: Any? {
var dict: [String: Any] = [:]

if before != nil {
dict["before"] = before
}

if after != nil {
dict["after"] = after
}

if perPage != nil {
dict["per_page"] = perPage
}

return dict
}
}
Expand Down
Loading