paystack_sdk 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +401 -2
- data/lib/paystack_sdk/client.rb +90 -0
- data/lib/paystack_sdk/resources/apple_pay.rb +74 -0
- data/lib/paystack_sdk/resources/bulk_charges.rb +131 -0
- data/lib/paystack_sdk/resources/direct_debits.rb +61 -0
- data/lib/paystack_sdk/resources/integrations.rb +48 -0
- data/lib/paystack_sdk/resources/orders.rb +146 -0
- data/lib/paystack_sdk/resources/pages.rb +192 -0
- data/lib/paystack_sdk/resources/products.rb +167 -0
- data/lib/paystack_sdk/resources/storefronts.rb +204 -0
- data/lib/paystack_sdk/resources/terminals.rb +170 -0
- data/lib/paystack_sdk/resources/virtual_terminals.rb +186 -0
- data/lib/paystack_sdk/version.rb +1 -1
- metadata +11 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Product`. Hand-written extras go in lib/paystack_sdk/resources/extensions/products.rb.
|
|
5
|
+
# scaffold-digest: 40ad36eb6641d3f3dc5f272c7c372ae279002d7bb64a3ac51b2ae5d8b4af3c5e
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Product operations.
|
|
12
|
+
class Products < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Products.
|
|
17
|
+
#
|
|
18
|
+
# List all previously created products
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per page
|
|
21
|
+
# @param page [Integer] The section to retrieve
|
|
22
|
+
# @param active [Boolean] The state of the product
|
|
23
|
+
# @param from [String] The start date
|
|
24
|
+
# @param to [String] The end date
|
|
25
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
26
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
27
|
+
# @see https://paystack.com/docs/api/product/#list
|
|
28
|
+
def list(per_page: nil, page: nil, active: nil, from: nil, to: nil)
|
|
29
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
30
|
+
validate_positive_integer!(value: page, name: "page")
|
|
31
|
+
|
|
32
|
+
wire_query = to_wire(
|
|
33
|
+
{
|
|
34
|
+
per_page:,
|
|
35
|
+
page:,
|
|
36
|
+
active:,
|
|
37
|
+
from: format_datetime(from, name: "from"),
|
|
38
|
+
to: format_datetime(to, name: "to")
|
|
39
|
+
},
|
|
40
|
+
WIRE_NAMES
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
handle_response(@connection.get("/product", wire_query))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Create Product.
|
|
47
|
+
#
|
|
48
|
+
# Create a new product on your integration
|
|
49
|
+
#
|
|
50
|
+
# @param name [String] Name of product
|
|
51
|
+
# @param price [Integer] Price should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
|
|
52
|
+
# @param currency [String] Currency in which price is set.
|
|
53
|
+
# @param description [String] The description of the product.
|
|
54
|
+
# @param unlimited [Boolean] Set to true if the product has unlimited stock.
|
|
55
|
+
# @param quantity [Integer] Number of products in stock.
|
|
56
|
+
# @param split_code [String] The split code if sharing the transaction with partners
|
|
57
|
+
# @param metadata [Hash] A set of key/value pairs that you can attach to the product.
|
|
58
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
59
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
60
|
+
# @see https://paystack.com/docs/api/product/#create
|
|
61
|
+
def create(
|
|
62
|
+
name:,
|
|
63
|
+
price:,
|
|
64
|
+
currency:,
|
|
65
|
+
description: nil,
|
|
66
|
+
unlimited: nil,
|
|
67
|
+
quantity: nil,
|
|
68
|
+
split_code: nil,
|
|
69
|
+
metadata: nil
|
|
70
|
+
)
|
|
71
|
+
validate_presence!(value: name, name: "name")
|
|
72
|
+
validate_presence!(value: price, name: "price")
|
|
73
|
+
validate_presence!(value: currency, name: "currency")
|
|
74
|
+
|
|
75
|
+
wire_body = to_wire(
|
|
76
|
+
{
|
|
77
|
+
name:,
|
|
78
|
+
price:,
|
|
79
|
+
currency:,
|
|
80
|
+
description:,
|
|
81
|
+
unlimited:,
|
|
82
|
+
quantity:,
|
|
83
|
+
split_code:,
|
|
84
|
+
metadata:
|
|
85
|
+
},
|
|
86
|
+
WIRE_NAMES
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
handle_response(@connection.post("/product", wire_body))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Fetch Product.
|
|
93
|
+
#
|
|
94
|
+
# Fetch a previously created product
|
|
95
|
+
#
|
|
96
|
+
# @param id [Integer] The unique identifier of the product
|
|
97
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
98
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
99
|
+
# @see https://paystack.com/docs/api/product/#fetch
|
|
100
|
+
def fetch(id:)
|
|
101
|
+
validate_presence!(value: id, name: "id")
|
|
102
|
+
|
|
103
|
+
handle_response(@connection.get("/product/#{escape_path(id, name: "id")}"))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Update product.
|
|
107
|
+
#
|
|
108
|
+
# Update a previously created product
|
|
109
|
+
#
|
|
110
|
+
# @param id [Integer] The unique identifier of the product
|
|
111
|
+
# @param name [String] Name of product
|
|
112
|
+
# @param description [String] The description of the product
|
|
113
|
+
# @param price [Integer] Price should be in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR
|
|
114
|
+
# @param currency [String] Currency in which price is set.
|
|
115
|
+
# @param unlimited [Boolean] Set to true if the product has unlimited stock.
|
|
116
|
+
# @param quantity [Integer] Number of products in stock.
|
|
117
|
+
# @param split_code [String] The split code if sharing the transaction with partners
|
|
118
|
+
# @param metadata [Hash] JSON object of custom data
|
|
119
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
120
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
121
|
+
# @see https://paystack.com/docs/api/product/#update
|
|
122
|
+
def update(
|
|
123
|
+
id:,
|
|
124
|
+
name: nil,
|
|
125
|
+
description: nil,
|
|
126
|
+
price: nil,
|
|
127
|
+
currency: nil,
|
|
128
|
+
unlimited: nil,
|
|
129
|
+
quantity: nil,
|
|
130
|
+
split_code: nil,
|
|
131
|
+
metadata: nil
|
|
132
|
+
)
|
|
133
|
+
validate_presence!(value: id, name: "id")
|
|
134
|
+
|
|
135
|
+
wire_body = to_wire(
|
|
136
|
+
{
|
|
137
|
+
name:,
|
|
138
|
+
description:,
|
|
139
|
+
price:,
|
|
140
|
+
currency:,
|
|
141
|
+
unlimited:,
|
|
142
|
+
quantity:,
|
|
143
|
+
split_code:,
|
|
144
|
+
metadata:
|
|
145
|
+
},
|
|
146
|
+
WIRE_NAMES
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
handle_response(@connection.put("/product/#{escape_path(id, name: "id")}", wire_body))
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Delete Product.
|
|
153
|
+
#
|
|
154
|
+
# Delete a previously created product
|
|
155
|
+
#
|
|
156
|
+
# @param id [Integer] The unique identifier of the product
|
|
157
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
158
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
159
|
+
# @see https://paystack.com/docs/api/product/#delete-product
|
|
160
|
+
def delete(id:)
|
|
161
|
+
validate_presence!(value: id, name: "id")
|
|
162
|
+
|
|
163
|
+
handle_response(@connection.delete("/product/#{escape_path(id, name: "id")}"))
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Storefront`. Hand-written extras go in lib/paystack_sdk/resources/extensions/storefronts.rb.
|
|
5
|
+
# scaffold-digest: c569580b4ac53036d82e0b7d2d9dd17323e11da35951df7ba4d192c5fdf48cb1
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Storefront operations.
|
|
12
|
+
class Storefronts < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {per_page: "perPage"}.freeze
|
|
15
|
+
|
|
16
|
+
# List Storefronts.
|
|
17
|
+
#
|
|
18
|
+
# List the storefronts you previously created
|
|
19
|
+
#
|
|
20
|
+
# @param per_page [Integer] Number of records to fetch per request
|
|
21
|
+
# @param page [Integer] The offset to retrieve data from
|
|
22
|
+
# @param status [String] One of: active, inactive.
|
|
23
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
24
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
25
|
+
# @see https://paystack.com/docs/api/storefront/#list
|
|
26
|
+
def list(per_page: nil, page: nil, status: nil)
|
|
27
|
+
validate_positive_integer!(value: per_page, name: "perPage")
|
|
28
|
+
validate_positive_integer!(value: page, name: "page")
|
|
29
|
+
validate_allowed_values!(value: status, allowed_values: %w[active inactive], name: "status")
|
|
30
|
+
|
|
31
|
+
wire_query = to_wire({per_page:, page:, status:}, WIRE_NAMES)
|
|
32
|
+
|
|
33
|
+
handle_response(@connection.get("/storefront", wire_query))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Create Storefront.
|
|
37
|
+
#
|
|
38
|
+
# Create a digital shop to manage and display your products
|
|
39
|
+
#
|
|
40
|
+
# @param name [String] Name of the storefront
|
|
41
|
+
# @param slug [String] A unique identifier to access your store.
|
|
42
|
+
# @param currency [String] Currency for prices of products in your storefront. One of: GHS, KES, NGN, USD, ZAR.
|
|
43
|
+
# @param description [String] The description of the storefront
|
|
44
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
45
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
46
|
+
# @see https://paystack.com/docs/api/storefront/#create
|
|
47
|
+
def create(name:, slug:, currency:, description: nil)
|
|
48
|
+
validate_presence!(value: name, name: "name")
|
|
49
|
+
validate_presence!(value: slug, name: "slug")
|
|
50
|
+
validate_presence!(value: currency, name: "currency")
|
|
51
|
+
validate_allowed_values!(
|
|
52
|
+
value: currency,
|
|
53
|
+
allowed_values: %w[GHS KES NGN USD ZAR],
|
|
54
|
+
name: "currency"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
wire_body = to_wire({name:, slug:, currency:, description:}, WIRE_NAMES)
|
|
58
|
+
|
|
59
|
+
handle_response(@connection.post("/storefront", wire_body))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Fetch Storefront.
|
|
63
|
+
#
|
|
64
|
+
# Get the details of a previously created Storefront
|
|
65
|
+
#
|
|
66
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
67
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
68
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
69
|
+
# @see https://paystack.com/docs/api/storefront/#fetch
|
|
70
|
+
def fetch(id:)
|
|
71
|
+
validate_presence!(value: id, name: "id")
|
|
72
|
+
|
|
73
|
+
handle_response(@connection.get("/storefront/#{escape_path(id, name: "id")}"))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Update Storefront.
|
|
77
|
+
#
|
|
78
|
+
# Update the details of a previously created Storefront
|
|
79
|
+
#
|
|
80
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
81
|
+
# @param name [String] Name of the storefront
|
|
82
|
+
# @param slug [String] A unique identifier to access your store.
|
|
83
|
+
# @param description [String] The description of the storefront
|
|
84
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
85
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
86
|
+
# @see https://paystack.com/docs/api/storefront/#update
|
|
87
|
+
def update(id:, name: nil, slug: nil, description: nil)
|
|
88
|
+
validate_presence!(value: id, name: "id")
|
|
89
|
+
|
|
90
|
+
wire_body = to_wire({name:, slug:, description:}, WIRE_NAMES)
|
|
91
|
+
|
|
92
|
+
handle_response(@connection.put("/storefront/#{escape_path(id, name: "id")}", wire_body))
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Delete Storefront.
|
|
96
|
+
#
|
|
97
|
+
# Delete a previously created Storefront
|
|
98
|
+
#
|
|
99
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
100
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
101
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
102
|
+
# @see https://paystack.com/docs/api/storefront/#delete
|
|
103
|
+
def delete(id:)
|
|
104
|
+
validate_presence!(value: id, name: "id")
|
|
105
|
+
|
|
106
|
+
handle_response(@connection.delete("/storefront/#{escape_path(id, name: "id")}"))
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Verify Storefront Slug.
|
|
110
|
+
#
|
|
111
|
+
# Verify the availability of a slug before using it for your Storefront
|
|
112
|
+
#
|
|
113
|
+
# @param slug [String] The custom slug to check
|
|
114
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
115
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
116
|
+
# @see https://paystack.com/docs/api/storefront/#verify-slug
|
|
117
|
+
def verify_slug(slug:)
|
|
118
|
+
validate_presence!(value: slug, name: "slug")
|
|
119
|
+
|
|
120
|
+
handle_response(@connection.get("/storefront/verify/#{escape_path(slug, name: "slug")}"))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Fetch Storefront Orders.
|
|
124
|
+
#
|
|
125
|
+
# Fetch all orders in your Storefront
|
|
126
|
+
#
|
|
127
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
128
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
129
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
130
|
+
# @see https://paystack.com/docs/api/storefront/#fetch-orders
|
|
131
|
+
def fetch_orders(id:)
|
|
132
|
+
validate_presence!(value: id, name: "id")
|
|
133
|
+
|
|
134
|
+
handle_response(@connection.get("/storefront/#{escape_path(id, name: "id")}/order"))
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# List Storefront Products.
|
|
138
|
+
#
|
|
139
|
+
# List the products in a Storefront
|
|
140
|
+
#
|
|
141
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
142
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
143
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
144
|
+
# @see https://paystack.com/docs/api/storefront/#list-products
|
|
145
|
+
def list_products(id:)
|
|
146
|
+
validate_presence!(value: id, name: "id")
|
|
147
|
+
|
|
148
|
+
handle_response(@connection.get("/storefront/#{escape_path(id, name: "id")}/product"))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Add Products to Storefront.
|
|
152
|
+
#
|
|
153
|
+
# Add previously created products to a Storefront
|
|
154
|
+
#
|
|
155
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
156
|
+
# @param products [Array] An array of product IDs
|
|
157
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
158
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
159
|
+
# @see https://paystack.com/docs/api/storefront/#add-products
|
|
160
|
+
def add_products(id:, products:)
|
|
161
|
+
validate_presence!(value: id, name: "id")
|
|
162
|
+
validate_presence!(value: products, name: "products")
|
|
163
|
+
|
|
164
|
+
wire_body = to_wire({products:}, WIRE_NAMES)
|
|
165
|
+
|
|
166
|
+
handle_response(
|
|
167
|
+
@connection.post("/storefront/#{escape_path(id, name: "id")}/product", wire_body)
|
|
168
|
+
)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Publish Storefront.
|
|
172
|
+
#
|
|
173
|
+
# Make your Storefront publicly available
|
|
174
|
+
#
|
|
175
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
176
|
+
# @note Publishing copies the storefront and its products into LIVE mode, even when you call
|
|
177
|
+
# it with a test key (sk_test_). The live copy is active, can be found by its slug, and
|
|
178
|
+
# cannot be read or deleted with a test key. Do not call this to try the API out; use
|
|
179
|
+
# `duplicate` instead.
|
|
180
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
181
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
182
|
+
# @see https://paystack.com/docs/api/storefront/#publish
|
|
183
|
+
def publish(id:)
|
|
184
|
+
validate_presence!(value: id, name: "id")
|
|
185
|
+
|
|
186
|
+
handle_response(@connection.post("/storefront/#{escape_path(id, name: "id")}/publish"))
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Duplicate Storefront.
|
|
190
|
+
#
|
|
191
|
+
# Duplicate a previously created Storefront
|
|
192
|
+
#
|
|
193
|
+
# @param id [Integer] The unique identifier of the Storefront
|
|
194
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
195
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
196
|
+
# @see https://paystack.com/docs/api/storefront/#duplicate
|
|
197
|
+
def duplicate(id:)
|
|
198
|
+
validate_presence!(value: id, name: "id")
|
|
199
|
+
|
|
200
|
+
handle_response(@connection.post("/storefront/#{escape_path(id, name: "id")}/duplicate"))
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Generated by bin/paystack-scaffold from Paystack's OpenAPI spec (PaystackOSS/openapi@d9d444d).
|
|
4
|
+
# Do not edit by hand: regenerate it with `bin/paystack-scaffold Terminal`. Hand-written extras go in lib/paystack_sdk/resources/extensions/terminals.rb.
|
|
5
|
+
# scaffold-digest: 0b01c27e31f3e144d9463553ec97a1eee95f91d173c35ca5b7cb500cd3872127
|
|
6
|
+
|
|
7
|
+
require_relative "base"
|
|
8
|
+
|
|
9
|
+
module PaystackSdk
|
|
10
|
+
module Resources
|
|
11
|
+
# Terminal operations.
|
|
12
|
+
class Terminals < PaystackSdk::Resources::Base
|
|
13
|
+
# Ruby keyword => the parameter name Paystack documents.
|
|
14
|
+
WIRE_NAMES = {next_cursor: "next"}.freeze
|
|
15
|
+
|
|
16
|
+
# Send Event.
|
|
17
|
+
#
|
|
18
|
+
# Send an event from your application to the Paystack Terminal
|
|
19
|
+
#
|
|
20
|
+
# @param terminal_id [String] The ID of the Terminal the event should be sent to.
|
|
21
|
+
# @param type [String] The type of event to push One of: invoice, transaction.
|
|
22
|
+
# @param action [String] The action the Terminal needs to perform. One of: process, view, print.
|
|
23
|
+
# @param data [Hash] The parameters needed to perform the specified action
|
|
24
|
+
# @note This pushes the event to a physical Paystack Terminal. Not verified against the
|
|
25
|
+
# Paystack API: the test account used to build this SDK has no Terminal access.
|
|
26
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
27
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
28
|
+
# @see https://paystack.com/docs/api/terminal/#send-event
|
|
29
|
+
def send_event(terminal_id:, type: nil, action: nil, data: nil)
|
|
30
|
+
validate_presence!(value: terminal_id, name: "terminal_id")
|
|
31
|
+
validate_allowed_values!(value: type, allowed_values: %w[invoice transaction], name: "type")
|
|
32
|
+
validate_allowed_values!(
|
|
33
|
+
value: action,
|
|
34
|
+
allowed_values: %w[process view print],
|
|
35
|
+
name: "action"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
wire_body = to_wire({type:, action:, data:}, WIRE_NAMES)
|
|
39
|
+
|
|
40
|
+
handle_response(
|
|
41
|
+
@connection.post("/terminal/#{escape_path(terminal_id, name: "terminal_id")}/event", wire_body)
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Fetch Event Status.
|
|
46
|
+
#
|
|
47
|
+
# Check the status of an event sent to the Terminal
|
|
48
|
+
#
|
|
49
|
+
# @param terminal_id [String] The ID of the Terminal the event should be sent to.
|
|
50
|
+
# @param event_id [String] The ID of the event that was sent to the Terminal
|
|
51
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
52
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
53
|
+
# @see https://paystack.com/docs/api/terminal/#fetch-event-status
|
|
54
|
+
def fetch_event_status(terminal_id:, event_id:)
|
|
55
|
+
validate_presence!(value: terminal_id, name: "terminal_id")
|
|
56
|
+
validate_presence!(value: event_id, name: "event_id")
|
|
57
|
+
|
|
58
|
+
handle_response(
|
|
59
|
+
@connection.get("/terminal/#{escape_path(terminal_id, name: "terminal_id")}/event/#{escape_path(event_id, name: "event_id")}")
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Fetch Terminal Status.
|
|
64
|
+
#
|
|
65
|
+
# Check the availiability of a Terminal before sending an event to it
|
|
66
|
+
#
|
|
67
|
+
# @param terminal_id [String] The ID of the Terminal the event should be sent to.
|
|
68
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
69
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
70
|
+
# @see https://paystack.com/docs/api/terminal/#fetch-terminal-status
|
|
71
|
+
def fetch_status(terminal_id:)
|
|
72
|
+
validate_presence!(value: terminal_id, name: "terminal_id")
|
|
73
|
+
|
|
74
|
+
handle_response(
|
|
75
|
+
@connection.get("/terminal/#{escape_path(terminal_id, name: "terminal_id")}/presence")
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# List Terminals.
|
|
80
|
+
#
|
|
81
|
+
# List the Terminals available on your integration
|
|
82
|
+
#
|
|
83
|
+
# @param next_cursor [String] A cursor that indicates your place in the list.
|
|
84
|
+
# @param previous [String] A cursor that indicates your place in the list.
|
|
85
|
+
# @param per_page [Integer] Specify how many records you want to retrieve per page
|
|
86
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
87
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
88
|
+
# @see https://paystack.com/docs/api/terminal/#list
|
|
89
|
+
def list(next_cursor: nil, previous: nil, per_page: nil)
|
|
90
|
+
validate_positive_integer!(value: per_page, name: "per_page")
|
|
91
|
+
|
|
92
|
+
wire_query = to_wire({next_cursor:, previous:, per_page:}, WIRE_NAMES)
|
|
93
|
+
|
|
94
|
+
handle_response(@connection.get("/terminal", wire_query))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Fetch Terminal.
|
|
98
|
+
#
|
|
99
|
+
# Get the details of a Terminal
|
|
100
|
+
#
|
|
101
|
+
# @param terminal_id [String] The ID of the Terminal the event should be sent to.
|
|
102
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
103
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
104
|
+
# @see https://paystack.com/docs/api/terminal/#fetch
|
|
105
|
+
def fetch(terminal_id:)
|
|
106
|
+
validate_presence!(value: terminal_id, name: "terminal_id")
|
|
107
|
+
|
|
108
|
+
handle_response(
|
|
109
|
+
@connection.get("/terminal/#{escape_path(terminal_id, name: "terminal_id")}")
|
|
110
|
+
)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Update Terminal.
|
|
114
|
+
#
|
|
115
|
+
# Update the details of a Terminal
|
|
116
|
+
#
|
|
117
|
+
# @param terminal_id [String] The ID of the Terminal the event should be sent to.
|
|
118
|
+
# @param name [String] The new name for the Terminal
|
|
119
|
+
# @param address [String] The new address for the Terminal
|
|
120
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
121
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
122
|
+
# @see https://paystack.com/docs/api/terminal/#update
|
|
123
|
+
def update(terminal_id:, name: nil, address: nil)
|
|
124
|
+
validate_presence!(value: terminal_id, name: "terminal_id")
|
|
125
|
+
|
|
126
|
+
wire_body = to_wire({name:, address:}, WIRE_NAMES)
|
|
127
|
+
|
|
128
|
+
handle_response(
|
|
129
|
+
@connection.put("/terminal/#{escape_path(terminal_id, name: "terminal_id")}", wire_body)
|
|
130
|
+
)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Commission Terminal.
|
|
134
|
+
#
|
|
135
|
+
# Activate your debug device by linking it to your integration
|
|
136
|
+
#
|
|
137
|
+
# @param serial_number [String] Device Serial Number
|
|
138
|
+
# @note This links a physical device to your integration. Not verified against the Paystack
|
|
139
|
+
# API: the test account used to build this SDK has no Terminal access.
|
|
140
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
141
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
142
|
+
# @see https://paystack.com/docs/api/terminal/#commission
|
|
143
|
+
def commission(serial_number:)
|
|
144
|
+
validate_presence!(value: serial_number, name: "serial_number")
|
|
145
|
+
|
|
146
|
+
wire_body = to_wire({serial_number:}, WIRE_NAMES)
|
|
147
|
+
|
|
148
|
+
handle_response(@connection.post("/terminal/commission_device", wire_body))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Decommission Terminal.
|
|
152
|
+
#
|
|
153
|
+
# Unlink your debug device from your integration
|
|
154
|
+
#
|
|
155
|
+
# @param serial_number [String] Device Serial Number
|
|
156
|
+
# @note This unlinks a physical device from your integration. Not verified against the
|
|
157
|
+
# Paystack API: the test account used to build this SDK has no Terminal access.
|
|
158
|
+
# @return [PaystackSdk::Response] The response from the Paystack API.
|
|
159
|
+
# @raise [PaystackSdk::Error] If a parameter is invalid or the API request fails.
|
|
160
|
+
# @see https://paystack.com/docs/api/terminal/#decommission
|
|
161
|
+
def decommission(serial_number:)
|
|
162
|
+
validate_presence!(value: serial_number, name: "serial_number")
|
|
163
|
+
|
|
164
|
+
wire_body = to_wire({serial_number:}, WIRE_NAMES)
|
|
165
|
+
|
|
166
|
+
handle_response(@connection.post("/terminal/decommission_device", wire_body))
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|