komoju 0.0.0 → 0.0.3

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.
@@ -0,0 +1,460 @@
1
+ # encoding: utf-8
2
+
3
+ #
4
+ # WARNING: Do not edit by hand, this file was generated by Heroics:
5
+ #
6
+ # https://github.com/interagent/heroics
7
+ #
8
+
9
+ require 'heroics'
10
+ require 'uri'
11
+
12
+ module Komoju
13
+ # Get a Client configured to use HTTP Basic authentication.
14
+ #
15
+ # @param api_key [String] The API key to use when connecting.
16
+ # @param options [Hash<Symbol,String>] Optionally, custom settings
17
+ # to use with the client. Allowed options are `default_headers`,
18
+ # `cache`, `user` and `url`.
19
+ # @return [Client] A client configured to use the API with HTTP Basic
20
+ # authentication.
21
+ def self.connect(api_key, options=nil)
22
+ options = custom_options(options)
23
+ uri = URI.parse(options[:url])
24
+ uri.user = URI.encode_www_form_component options.fetch(:user, 'user')
25
+ uri.password = api_key
26
+ client = Heroics.client_from_schema(SCHEMA, uri.to_s, options)
27
+ Client.new(client)
28
+ end
29
+
30
+ # Get a Client configured to use OAuth authentication.
31
+ #
32
+ # @param oauth_token [String] The OAuth token to use with the API.
33
+ # @param options [Hash<Symbol,String>] Optionally, custom settings
34
+ # to use with the client. Allowed options are `default_headers`,
35
+ # `cache` and `url`.
36
+ # @return [Client] A client configured to use the API with OAuth
37
+ # authentication.
38
+ def self.connect_oauth(oauth_token, options=nil)
39
+ options = custom_options(options)
40
+ url = options[:url]
41
+ client = Heroics.oauth_client_from_schema(oauth_token, SCHEMA, url, options)
42
+ Client.new(client)
43
+ end
44
+
45
+ # Get a Client configured to use Token authentication.
46
+ #
47
+ # @param token [String] The token to use with the API.
48
+ # @param options [Hash<Symbol,String>] Optionally, custom settings
49
+ # to use with the client. Allowed options are `default_headers`,
50
+ # `cache` and `url`.
51
+ # @return [Client] A client configured to use the API with OAuth
52
+ # authentication.
53
+ def self.connect_token(token, options=nil)
54
+ options = custom_options(options)
55
+ url = options[:url]
56
+ client = Heroics.token_client_from_schema(token, SCHEMA, url, options)
57
+ Client.new(client)
58
+ end
59
+
60
+ # Get customized options.
61
+ def self.custom_options(options)
62
+ return default_options if options.nil?
63
+
64
+ final_options = default_options
65
+ if options[:default_headers]
66
+ final_options[:default_headers].merge!(options[:default_headers])
67
+ end
68
+ final_options[:cache] = options[:cache] if options[:cache]
69
+ final_options[:url] = options[:url] if options[:url]
70
+ final_options[:user] = options[:user] if options[:user]
71
+ final_options
72
+ end
73
+
74
+ # Get the default options.
75
+ def self.default_options
76
+ default_headers = {}
77
+ cache = {}
78
+ {
79
+ default_headers: default_headers,
80
+ cache: cache,
81
+ url: "https://komoju.com/api/v1"
82
+ }
83
+ end
84
+
85
+ private_class_method :default_options, :custom_options
86
+
87
+ # Komoju API auto-generated JSON Schema
88
+ class Client
89
+ def initialize(client)
90
+ @client = client
91
+ end
92
+
93
+ # Event Resource
94
+ #
95
+ # @return [Events]
96
+ def events
97
+ @events_resource ||= Events.new(@client)
98
+ end
99
+
100
+ # Payment resource
101
+ #
102
+ # @return [Payments]
103
+ def payments
104
+ @payments_resource ||= Payments.new(@client)
105
+ end
106
+
107
+ # Payout Resource
108
+ #
109
+ # @return [Payouts]
110
+ def payouts
111
+ @payouts_resource ||= Payouts.new(@client)
112
+ end
113
+
114
+ # Subscription Resource
115
+ #
116
+ # @return [Subscriptions]
117
+ def subscriptions
118
+ @subscriptions_resource ||= Subscriptions.new(@client)
119
+ end
120
+
121
+ # Subscription Customers
122
+ #
123
+ # @return [Customers]
124
+ def customers
125
+ @customers_resource ||= Customers.new(@client)
126
+ end
127
+
128
+ # Subscription Invoice
129
+ #
130
+ # @return [Invoices]
131
+ def invoices
132
+ @invoices_resource ||= Invoices.new(@client)
133
+ end
134
+
135
+ # Subscription Invoice Items
136
+ #
137
+ # @return [InvoiceItems]
138
+ def invoice_items
139
+ @invoice_items_resource ||= InvoiceItems.new(@client)
140
+ end
141
+
142
+ # Subscription Plans
143
+ #
144
+ # @return [Plans]
145
+ def plans
146
+ @plans_resource ||= Plans.new(@client)
147
+ end
148
+
149
+ # Token resource
150
+ #
151
+ # @return [Tokens]
152
+ def tokens
153
+ @tokens_resource ||= Tokens.new(@client)
154
+ end
155
+ end
156
+
157
+ private
158
+
159
+ # Event Resource
160
+ class Events
161
+ def initialize(client)
162
+ @client = client
163
+ end
164
+
165
+ # List events
166
+ #
167
+ # @param collection_options: additional collection options to pass with the request
168
+ def list(collection_options = {})
169
+ @client.events.list(collection_options)
170
+ end
171
+
172
+ # Show a event
173
+ #
174
+ # @param events_id: A unique identifier for an event.
175
+ def show(events_id)
176
+ @client.events.show(events_id)
177
+ end
178
+ end
179
+
180
+ # Payment resource
181
+ class Payments
182
+ def initialize(client)
183
+ @client = client
184
+ end
185
+
186
+ # List payments
187
+ #
188
+ # @param collection_options: additional collection options to pass with the request
189
+ def list(collection_options = {})
190
+ @client.payments.list(collection_options)
191
+ end
192
+
193
+ # Show a payment
194
+ #
195
+ # @param payments_id: A unique indentifier for the payment
196
+ def show(payments_id)
197
+ @client.payments.show(payments_id)
198
+ end
199
+
200
+ # Create a payment
201
+ #
202
+ # @param body: the object to pass as the request payload
203
+ def create(body)
204
+ @client.payments.create(body)
205
+ end
206
+
207
+ # Update a payment
208
+ #
209
+ # @param payments_id: A unique indentifier for the payment
210
+ # @param body: the object to pass as the request payload
211
+ def update(payments_id, body)
212
+ @client.payments.update(payments_id, body)
213
+ end
214
+
215
+ # Refund a payment
216
+ #
217
+ # @param payments_id: A unique indentifier for the payment
218
+ # @param body: the object to pass as the request payload
219
+ def refund(payments_id, body)
220
+ @client.payments.refund(payments_id, body)
221
+ end
222
+
223
+ # Cancel a payment
224
+ #
225
+ # @param payments_id: A unique indentifier for the payment
226
+ def cancel(payments_id)
227
+ @client.payments.cancel(payments_id)
228
+ end
229
+ end
230
+
231
+ # Payout Resource
232
+ class Payouts
233
+ def initialize(client)
234
+ @client = client
235
+ end
236
+
237
+ # List payouts
238
+ #
239
+ # @param collection_options: additional collection options to pass with the request
240
+ def list(collection_options = {})
241
+ @client.payouts.list(collection_options)
242
+ end
243
+
244
+ # Show a payout
245
+ #
246
+ # @param payouts_id: A unique identifier for a payout.
247
+ def show(payouts_id)
248
+ @client.payouts.show(payouts_id)
249
+ end
250
+
251
+ # List payout items
252
+ #
253
+ # @param payouts_id: A unique identifier for a payout.
254
+ # @param collection_options: additional collection options to pass with the request
255
+ def payout_items(payouts_id, collection_options = {})
256
+ @client.payouts.payout_items(payouts_id, collection_options)
257
+ end
258
+ end
259
+
260
+ # Subscription Resource
261
+ class Subscriptions
262
+ def initialize(client)
263
+ @client = client
264
+ end
265
+
266
+ # List subscriptions
267
+ #
268
+ # @param collection_options: additional collection options to pass with the request
269
+ def list(collection_options = {})
270
+ @client.subscriptions.list(collection_options)
271
+ end
272
+
273
+ # Show a subscription
274
+ #
275
+ # @param subscriptions_id: A unique identifier for a subscription.
276
+ def show(subscriptions_id)
277
+ @client.subscriptions.show(subscriptions_id)
278
+ end
279
+
280
+ # Create a subscription
281
+ #
282
+ # @param body: the object to pass as the request payload
283
+ def create(body)
284
+ @client.subscriptions.create(body)
285
+ end
286
+
287
+ # Destroy a subscription
288
+ #
289
+ # @param subscriptions_id: A unique identifier for a subscription.
290
+ def destroy(subscriptions_id)
291
+ @client.subscriptions.destroy(subscriptions_id)
292
+ end
293
+ end
294
+
295
+ # Subscription Customers
296
+ class Customers
297
+ def initialize(client)
298
+ @client = client
299
+ end
300
+
301
+ # List customers
302
+ #
303
+ # @param collection_options: additional collection options to pass with the request
304
+ def list(collection_options = {})
305
+ @client.customers.list(collection_options)
306
+ end
307
+
308
+ # Show a customer
309
+ #
310
+ # @param customers_id: A unique identifier for the customer.
311
+ def show(customers_id)
312
+ @client.customers.show(customers_id)
313
+ end
314
+
315
+ # Create a customer
316
+ #
317
+ # @param body: the object to pass as the request payload
318
+ def create(body)
319
+ @client.customers.create(body)
320
+ end
321
+
322
+ # Update customers
323
+ #
324
+ # @param customers_id: A unique identifier for the customer.
325
+ # @param body: the object to pass as the request payload
326
+ def update(customers_id, body)
327
+ @client.customers.update(customers_id, body)
328
+ end
329
+
330
+ # Destroy a customer
331
+ #
332
+ # @param customers_id: A unique identifier for the customer.
333
+ def destroy(customers_id)
334
+ @client.customers.destroy(customers_id)
335
+ end
336
+ end
337
+
338
+ # Subscription Invoice
339
+ class Invoices
340
+ def initialize(client)
341
+ @client = client
342
+ end
343
+
344
+ # List invoices
345
+ #
346
+ # @param collection_options: additional collection options to pass with the request
347
+ def list(collection_options = {})
348
+ @client.invoices.list(collection_options)
349
+ end
350
+
351
+ # Show an invoice
352
+ #
353
+ # @param invoices_id: A unique identifier for the invoice.
354
+ def show(invoices_id)
355
+ @client.invoices.show(invoices_id)
356
+ end
357
+
358
+ # Create an invoice
359
+ #
360
+ # @param body: the object to pass as the request payload
361
+ def create(body)
362
+ @client.invoices.create(body)
363
+ end
364
+
365
+ # Preview an upcoming invoice
366
+ #
367
+ # @param body: the object to pass as the request payload
368
+ def preview(body)
369
+ @client.invoices.preview(body)
370
+ end
371
+ end
372
+
373
+ # Subscription Invoice Items
374
+ class InvoiceItems
375
+ def initialize(client)
376
+ @client = client
377
+ end
378
+
379
+ # List invoice items
380
+ #
381
+ # @param collection_options: additional collection options to pass with the request
382
+ def list(collection_options = {})
383
+ @client.invoice_items.list(collection_options)
384
+ end
385
+
386
+ # Show an invoice item
387
+ #
388
+ # @param invoice_items_id: A unique identifier for the invoice items.
389
+ def show(invoice_items_id)
390
+ @client.invoice_items.show(invoice_items_id)
391
+ end
392
+
393
+ # Create an invoice item
394
+ #
395
+ # @param body: the object to pass as the request payload
396
+ def create(body)
397
+ @client.invoice_items.create(body)
398
+ end
399
+
400
+ # Deletes an invoice item from the upcoming invoice.
401
+ #
402
+ # @param invoice_items_id: A unique identifier for the invoice items.
403
+ def destroy(invoice_items_id)
404
+ @client.invoice_items.destroy(invoice_items_id)
405
+ end
406
+ end
407
+
408
+ # Subscription Plans
409
+ class Plans
410
+ def initialize(client)
411
+ @client = client
412
+ end
413
+
414
+ # List plans
415
+ #
416
+ # @param collection_options: additional collection options to pass with the request
417
+ def list(collection_options = {})
418
+ @client.plans.list(collection_options)
419
+ end
420
+
421
+ # Show a plan
422
+ #
423
+ # @param plans_name: Name of the plan.
424
+ def show(plans_name)
425
+ @client.plans.show(plans_name)
426
+ end
427
+
428
+ # Create a plan
429
+ #
430
+ # @param body: the object to pass as the request payload
431
+ def create(body)
432
+ @client.plans.create(body)
433
+ end
434
+
435
+ # Destroy a plan
436
+ #
437
+ # @param plans_name: Name of the plan.
438
+ def destroy(plans_name)
439
+ @client.plans.destroy(plans_name)
440
+ end
441
+ end
442
+
443
+ # Token resource
444
+ class Tokens
445
+ def initialize(client)
446
+ @client = client
447
+ end
448
+
449
+ # Create a token
450
+ #
451
+ # @param body: the object to pass as the request payload
452
+ def create(body)
453
+ @client.tokens.create(body)
454
+ end
455
+ end
456
+
457
+ SCHEMA = Heroics::Schema.new(MultiJson.load(<<-'HEROICS_SCHEMA'))
458
+ {"$schema":"http://json-schema.org/draft-04/hyper-schema","definitions":{"list":{"type":["object"],"properties":{"resource":{"enum":["list"]},"total":{"type":["integer"]},"page":{"type":["integer"]},"per_page":{"type":["integer"]},"last_page":{"type":["integer"]},"data":{"oneOf":[{"type":["array"],"items":{"$ref":"#/definitions/payments"}},{"type":["array"],"items":{"$ref":"#/definitions/payouts"}},{"type":["array"],"items":{"$ref":"#/definitions/payouts/definitions/payout_item"}},{"type":["array"],"items":{"$ref":"#/definitions/events"}},{"type":["array"],"items":{"$ref":"#/definitions/tokens"}},{"type":["array"],"items":{"$ref":"#/definitions/customers"}},{"type":["array"],"items":{"$ref":"#/definitions/plans"}},{"type":["array"],"items":{"$ref":"#/definitions/subscriptions"}},{"type":["array"],"items":{"$ref":"#/definitions/invoices"}},{"type":["array"],"items":{"$ref":"#/definitions/invoice_items"}}]}}},"events":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"66a4824ac97cc7afff608f27c7","readOnly":true,"type":["string"],"description":"A unique identifier for an event."},"type":{"example":"payment.authorized","readOnly":true,"type":["string"]},"data":{"readOnly":true,"type":["object"],"description":"An object which creates an event"},"resource":{"example":"event","readOnly":true,"enum":["event"],"description":"Name of resource"},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","readOnly":true,"type":["string"],"description":"An ISO 8601 formatted timestamp of when the event was created."}},"links":[{"title":"List","description":"List events","href":"/events","method":"GET","rel":"instances","response_example":"events#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a event","href":"/events/{(%2Fdefinitions%2Fevents%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"events#show","targetSchema":{"$ref":"#/definitions/events/"}}],"properties":{"id":{"$ref":"#/definitions/events/definitions/id"},"type":{"$ref":"#/definitions/events/definitions/type"},"resource":{"$ref":"#/definitions/events/definitions/resource"},"data":{"$ref":"#/definitions/events/definitions/data"},"created_at":{"$ref":"#/definitions/events/definitions/created_at"}},"description":"Event Resource","title":"Events"},"payments":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"given_name":{"type":["string"]},"family_name":{"type":["string"]},"given_name_kana":{"type":["string"]},"family_name_kana":{"type":["string"]},"email":{"type":["string"],"format":"email"},"phone":{"type":["string"],"pattern":"\\A([() \\-_+]*[0-9]){10}[() \\-_+0-9]*\\Z"},"expiry_days":{"type":["integer"],"minimum":0,"maximum":59,"exclusiveMinimum":false,"exclusiveMaximum":false},"instructions_url":{"type":["string"],"format":"uri"},"external_order_num":{"type":["string"]},"bank_transfer_request":{"type":["object"],"properties":{"type":{"enum":["bank_transfer"]},"phone":{"$ref":"#/definitions/payments/definitions/phone"},"email":{"$ref":"#/definitions/payments/definitions/email"},"given_name":{"$ref":"#/definitions/payments/definitions/given_name"},"family_name":{"$ref":"#/definitions/payments/definitions/family_name"},"given_name_kana":{"$ref":"#/definitions/payments/definitions/given_name_kana"},"family_name_kana":{"$ref":"#/definitions/payments/definitions/family_name_kana"},"expiry_days":{"$ref":"#/definitions/payments/definitions/expiry_days"}},"required":["type","given_name","family_name","given_name_kana","family_name_kana","phone","email"]},"bank_transfer_response":{"type":["object"],"properties":{"type":{"enum":["bank_transfer"]},"email":{"$ref":"#/definitions/payments/definitions/email"},"order_id":{"type":["string"]},"bank_name":{"type":["string"]},"account_number":{"type":["integer"]},"account_type":{"type":["string"]},"account_name":{"type":["string"]}},"required":["type","email","order_id","bank_name","account_number","account_type","account_name"]},"konbini_request":{"type":["object"],"properties":{"type":{"enum":["konbini"]},"store":{"enum":["seven-eleven","lawson","family-mart","sunkus","circle-k","ministop","daily-yamazaki"]},"email":{"$ref":"#/definitions/payments/definitions/email"},"phone":{"$ref":"#/definitions/payments/definitions/phone"},"expiry_days":{"$ref":"#/definitions/payments/definitions/expiry_days"}},"required":["type","store","phone","email"]},"konbini_response":{"type":["object"],"properties":{"type":{"enum":["konbini"]},"store":{"enum":["seven-eleven","lawson","family-mart","sunkus","circle-k","ministop","daily-yamazaki"]},"instructions_url":{"$ref":"#/definitions/payments/definitions/instructions_url"},"confirmation_code":{"type":["string"]},"receipt":{"type":["string"]}},"required":["type","store","confirmation_code","receipt","instructions_url"]},"pay_easy_request":{"type":["object"],"properties":{"type":{"enum":["pay_easy"]},"email":{"$ref":"#/definitions/payments/definitions/email"},"given_name":{"$ref":"#/definitions/payments/definitions/given_name"},"family_name":{"$ref":"#/definitions/payments/definitions/family_name"},"given_name_kana":{"$ref":"#/definitions/payments/definitions/given_name_kana"},"family_name_kana":{"$ref":"#/definitions/payments/definitions/family_name_kana"},"instructions_url":{"$ref":"#/definitions/payments/definitions/instructions_url"},"phone":{"$ref":"#/definitions/payments/definitions/phone"},"expiry_days":{"$ref":"#/definitions/payments/definitions/expiry_days"}},"required":["type","given_name","family_name","given_name_kana","family_name_kana","email","phone"]},"pay_easy_response":{"type":["object"],"properties":{"type":{"enum":["pay_easy"]},"pay_url":{"type":["string"]},"instructions_url":{"$ref":"#/definitions/payments/definitions/instructions_url"}},"required":["type","pay_url","instructions_url"]},"web_money_request":{"type":["object"],"properties":{"type":{"enum":["web_money"]},"prepaid_number":{"type":["string"],"maxLength":16}},"required":["type","prepaid_number"]},"web_money_response":{"type":["object"],"properties":{"type":{"enum":["web_money"]},"short_amount":{"type":["integer"]}},"required":["type","short_amount"]},"credit_card_request":{"type":["object"],"properties":{"type":{"enum":["credit_card"]},"number":{"type":["string"]},"month":{"type":["integer"]},"year":{"type":["integer"]},"verification_value":{"type":["string"]},"given_name":{"$ref":"#/definitions/payments/definitions/given_name"},"family_name":{"$ref":"#/definitions/payments/definitions/family_name"},"last_four_digits":{"type":["string"]},"brand":{"enum":["visa","american_express","master","jcb"]}},"required":["type","number","month","year","given_name","family_name"]},"credit_card_response":{"type":["object"],"properties":{"type":{"enum":["credit_card"]},"month":{"type":["integer"]},"year":{"type":["integer"]},"last_four_digits":{"type":["string"]},"brand":{"enum":["visa","american_express","master","jcb"]}},"required":["type","brand","last_four_digits","month","year"]},"id":{"example":"94f128d4021b049bc616f5b1b0","readOnly":true,"type":["string"],"description":"A unique indentifier for the payment"},"resource":{"example":"payment","enum":["payment"],"description":"Value of `resource`."},"status":{"example":"pending","enum":["pending","authorized","captured","expired","cancelled","refunded"],"description":"The status of the payment."},"amount":{"example":"300","minimum":0,"type":["number"],"description":"The amount to be charged before tax. Must be equal or greater than 0. Use a ‘.’ as a decimal separator, and no thousands separator"},"tax":{"example":"30","type":["number","null"],"description":"The amount of tax to be charged, or ‘auto’ to use the current consumption tax rate in Japan. Use a ‘.’ as a decimal separator, and no thousands separator. If the tax is more precise than the currency allows, it will be rounded using a round half up algorithm."},"payment_deadline":{"format":"date-time","example":"2015-03-09T06:52:34Z","type":["string","null"],"description":"Time when the payment will expire. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ."},"payment_method_fee":{"example":"0","type":["number"],"minimum":0,"description":"An additional fee added to specific payment types"},"total":{"example":"330","type":["number"],"description":"The payment total, this is the amount + tax + payment_method_fee"},"currency":{"example":"JPY","enum":["JPY","USD"],"description":"3 letter ISO currency code of the transaction"},"description":{"example":"","type":["string","null"],"description":"Description of the payment (used in e-mail receipts if enabled)."},"subscription":{"example":null,"type":["object","null"],"description":"Shown if payment was part of a subscription"},"captured_at":{"example":"2015-03-09T06:52:34Z","type":["string","null"],"description":"An ISO 8601 formatted timestamp of when a payment was captured"},"metadata":{"type":["object","null"],"example":{"order_id":"abcdefghijklmn"},"description":"A set of key-value pairs"},"payment_details_request":{"description":"A hash or token describing the payment method used to make the payment.","example":{"type":["konbini"],"store":"lawson","email":"foo@bar.com","phone":"08011111111"},"type":["string","object"],"properties":{"type":{"enum":["credit_card","bank_transfer","konbini","pay_easy","web_money"]}},"required":["type"]},"payment_details_response":{"description":"A hash or token describing the payment method used to make the payment.","example":{"type":["konbini"],"store":"lawson","confirmation_code":null,"receipt":"12345"},"oneOf":[{"type":["null"]},{"$ref":"#/definitions/payments/definitions/bank_transfer_response"},{"$ref":"#/definitions/payments/definitions/credit_card_response"},{"$ref":"#/definitions/payments/definitions/konbini_response"},{"$ref":"#/definitions/payments/definitions/pay_easy_response"},{"$ref":"#/definitions/payments/definitions/web_money_response"}]},"fraud_details":{"type":["object","null"],"properties":{"customer_ip":{"format":"ipv4","type":["string"]},"customer_email":{"format":"email","type":["string"]},"browser_language":{"type":["string"]},"browser_user_agent":{"type":["string"]}},"dependencies":{"customer_email":["customer_ip"],"browser_language":["customer_ip"],"browser_user_agent":["customer_ip"]},"additionalProperties":false},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","type":["string"],"description":"An ISO 8601 formatted timestamp of when a payment was created"}},"links":[{"title":"List","description":"List payments","href":"/payments","method":"GET","rel":"instances","response_example":"payments#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a payment","href":"/payments/{(%2Fdefinitions%2Fpayments%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"payments#show","targetSchema":{"$ref":"#/definitions/payments/"}},{"title":"Create","description":"Create a payment","href":"/payments","method":"POST","rel":"create","response_example":"payments#create","targetSchema":{"$ref":"#/definitions/payments/"},"schema":{"type":["object"],"properties":{"amount":{"$ref":"#/definitions/payments/definitions/amount"},"tax":{"$ref":"#/definitions/payments/definitions/tax"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"external_order_num":{"$ref":"#/definitions/payments/definitions/external_order_num"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_request"},"fraud_details":{"$ref":"#/definitions/payments/definitions/fraud_details"}},"required":["amount","currency","payment_details"],"additionalProperties":false}},{"title":"Update","description":"Update a payment","href":"/payments/{(%2Fdefinitions%2Fpayments%2Fdefinitions%2Fid)}","method":"PATCH","rel":"self","response_example":"payments#update","targetSchema":{"$ref":"#/definitions/payments/"},"schema":{"type":["object"],"properties":{"description":{"$ref":"#/definitions/payments/definitions/description"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"payment_details":{"type":["object"],"properties":{"type":{"enum":["web_money"]}},"required":["type"]}},"additionalProperties":false}},{"title":"Refund","description":"Refund a payment","href":"/payments/{(%2Fdefinitions%2Fpayments%2Fdefinitions%2Fid)}/refund","method":"POST","rel":"self","response_example":"payments#refund","targetSchema":{"$ref":"#/definitions/payments/"},"schema":{"type":["object"],"properties":{"amount":{"$ref":"#/definitions/payments/definitions/amount"},"description":{"$ref":"#/definitions/payments/definitions/description"}}}},{"title":"Cancel","description":"Cancel a payment","href":"/payments/{(%2Fdefinitions%2Fpayments%2Fdefinitions%2Fid)}/cancel","method":"POST","rel":"self","response_example":"payments#cancel","targetSchema":{"$ref":"#/definitions/payments/"}}],"properties":{"id":{"$ref":"#/definitions/payments/definitions/id"},"resource":{"$ref":"#/definitions/payments/definitions/resource"},"status":{"$ref":"#/definitions/payments/definitions/status"},"amount":{"$ref":"#/definitions/payments/definitions/amount"},"tax":{"$ref":"#/definitions/payments/definitions/tax"},"payment_deadline":{"$ref":"#/definitions/payments/definitions/payment_deadline"},"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_response"},"payment_method_fee":{"$ref":"#/definitions/payments/definitions/payment_method_fee"},"total":{"$ref":"#/definitions/payments/definitions/total"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"description":{"$ref":"#/definitions/payments/definitions/description"},"subscription":{"$ref":"#/definitions/payments/definitions/subscription"},"captured_at":{"$ref":"#/definitions/payments/definitions/captured_at"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"created_at":{"$ref":"#/definitions/payments/definitions/created_at"},"refunds":{"type":["array"]}},"description":"Payment resource","title":"Payments"},"payouts":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"66a4824ac97cc7afff608f27c7","readOnly":true,"type":["string"],"description":"A unique identifier for a payout."},"resource":{"example":"event","readOnly":true,"enum":["payout"],"description":"Name of resource"},"payout_item":{"readOnly":true,"type":["object"],"properties":{"resource":{"example":"payout_item","readOnly":true,"enum":["payout_item"],"description":"Name of resource."},"event_type":{"example":"capture","readOnly":true,"enum":["capture","refund"],"description":"Describes whether the payout item is from a captured or refunded payment."},"timestamp":{"example":"2015-03-06T06:52:35Z","readOnly":true,"format":"date-time","description":"Timestamp describing when the payment was either captured or refunded."},"payment_method":{"example":"visa","readOnly":true,"enum":["visa","master_card","american_express","jcb","bank_transfer","web_money","lawson","family-mart","sunkus","circle-k","ministop","daily-yamazaki","seven-eleven"],"description":"The payment method of the payment."},"payment_fee":{"example":"300","type":["number"],"description":"Komoju platform fee deducted from the payment total."},"receivable":{"example":"300","type":["number"],"description":"The amount paid to your account for a given payment."},"amount":{"$ref":"#/definitions/payments/definitions/amount"},"tax":{"$ref":"#/definitions/payments/definitions/tax"},"total":{"$ref":"#/definitions/payments/definitions/total"}},"description":"Payout Item Resource"},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","readOnly":true,"type":["string"],"description":"An ISO 8601 formatted timestamp of when the payout was created."}},"links":[{"title":"List","description":"List payouts","href":"/payouts","method":"GET","rel":"instances","response_example":"payouts#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a payout","href":"/payouts/{(%2Fdefinitions%2Fpayouts%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"payouts#show","targetSchema":{"$ref":"#/definitions/payouts/"}},{"title":"Payout Items","description":"List payout items","href":"/payouts/{(%2Fdefinitions%2Fpayouts%2Fdefinitions%2Fid)}/payout_items","method":"GET","rel":"instances","response_example":"payouts#payout_items","targetSchema":{"$ref":"#/definitions/list/"}}],"properties":{"id":{"$ref":"#/definitions/payouts/definitions/id"},"resource":{"$ref":"#/definitions/payouts/definitions/resource"},"payout_items":{"$ref":"#/definitions/list/"},"created_at":{"$ref":"#/definitions/payouts/definitions/created_at"}},"description":"Payout Resource","title":"Payouts"},"subscriptions":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"66a4824ac97cc7afff608f27c7","readOnly":true,"type":["string"],"description":"A unique identifier for a subscription."},"resource":{"example":"subscription","readOnly":true,"enum":["subscription"],"description":"Name of resource"},"status":{"example":"pending","readOnly":true,"enum":["cancelled","pending","active","past_due"],"description":"The status of the subscription."},"plan":{"$ref":"#/definitions/plans"},"customer":{"$ref":"#/definitions/customers"},"current_period_end_at":{"example":null,"format":"date-time","readOnly":true,"type":["string","null"],"description":"An ISO 8601 formatted timestamp of when the subscription will next be billed."},"cancel_at_period_end":{"type":["boolean"]},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","readOnly":true,"type":["string"],"description":"An ISO 8601 formatted timestamp of when the plan was created."}},"links":[{"title":"List","description":"List subscriptions","href":"/subscriptions","method":"GET","rel":"instances","response_example":"subscriptions#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a subscription","href":"/subscriptions/{(%2Fdefinitions%2Fsubscriptions%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"subscriptions#show","targetSchema":{"$ref":"#/definitions/subscriptions/"}},{"title":"Create","description":"Create a subscription","href":"/subscriptions","method":"POST","rel":"create","response_example":"subscriptions#create","targetSchema":{"$ref":"#/definitions/subscriptions/"},"schema":{"type":["object"],"properties":{"customer":{"type":["string"]},"plan":{"type":["string"]},"metadata":{"$ref":"#/definitions/subscriptions/definitions/metadata"}},"required":["customer","plan"]}},{"title":"Destroy","description":"Destroy a subscription","href":"/subscriptions/{(%2Fdefinitions%2Fsubscriptions%2Fdefinitions%2Fid)}","method":"DELETE","rel":"destroy","response_example":"subscriptions#destroy","targetSchema":{"$ref":"#/definitions/subscriptions/"}}],"properties":{"id":{"$ref":"#/definitions/subscriptions/definitions/id"},"resource":{"$ref":"#/definitions/subscriptions/definitions/resource"},"status":{"$ref":"#/definitions/subscriptions/definitions/status"},"plan":{"$ref":"#/definitions/subscriptions/definitions/plan"},"customer":{"$ref":"#/definitions/subscriptions/definitions/customer"},"current_period_end_at":{"$ref":"#/definitions/subscriptions/definitions/current_period_end_at"},"metadata":{"$ref":"#/definitions/subscriptions/definitions/metadata"},"created_at":{"$ref":"#/definitions/subscriptions/definitions/created_at"}},"description":"Subscription Resource","title":"Subscriptions"},"customers":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"fa799fca14be29d3fae455f22d","readOnly":true,"type":["string"],"description":"A unique identifier for the customer."},"resource":{"example":"customer","readOnly":true,"enum":["customer"],"description":"Name of resource"},"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_response"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"email":{"type":["string","null"],"format":"email","description":"Customer's email address."},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","readOnly":true,"type":["string"],"description":"An ISO 8601 formatted timestamp of when the customer was created."}},"links":[{"title":"List","description":"List customers","href":"/customers","method":"GET","rel":"instances","response_example":"customers#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a customer","href":"/customers/{(%2Fdefinitions%2Fcustomers%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"customers#show","targetSchema":{"$ref":"#/definitions/customers/"}},{"title":"Create","description":"Create a customer","href":"/customers","method":"POST","rel":"create","response_example":"customers#create","targetSchema":{"$ref":"#/definitions/customers/"},"schema":{"type":["object"],"properties":{"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_request"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"email":{"$ref":"#/definitions/customers/definitions/email"},"metadata":{"$ref":"#/definitions/customers/definitions/metadata"}},"required":["currency","payment_details"],"additionalFields":false}},{"title":"Update","description":"Update customers","href":"/customers/{(%2Fdefinitions%2Fcustomers%2Fdefinitions%2Fid)}","method":"PATCH","rel":"self","response_example":"customers#update","schema":{"type":["object"],"properties":{"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_request"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"email":{"$ref":"#/definitions/customers/definitions/email"},"metadata":{"$ref":"#/definitions/customers/definitions/metadata"}},"required":["payment_details"],"additionalFields":false},"targetSchema":{"$ref":"#/definitions/customers/"}},{"title":"Destroy","description":"Destroy a customer","href":"/customers/{(%2Fdefinitions%2Fcustomers%2Fdefinitions%2Fid)}","method":"DELETE","rel":"destroy","response_example":"customers#destroy","targetSchema":{"$ref":"#/definitions/customers/"}}],"properties":{"id":{"$ref":"#/definitions/customers/definitions/id"},"resource":{"$ref":"#/definitions/customers/definitions/resource"},"email":{"$ref":"#/definitions/customers/definitions/email"},"metadata":{"$ref":"#/definitions/customers/definitions/metadata"},"created_at":{"$ref":"#/definitions/customers/definitions/created_at"}},"description":"Subscription Customers","title":"Customers"},"invoices":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"66a4824ac97cc7afff608f27c7","readOnly":true,"type":["string"],"description":"A unique identifier for the invoice."},"resource":{"example":"invoice","readOnly":true,"enum":["invoice"],"description":"Name of resource."},"invoice":{"readOnly":true,"type":["string","null"]},"paid":{"readOnly":true,"type":["boolean"]},"created_at":{"readOnly":true,"format":"date-time","type":["string","null"],"description":"An ISO 8601 formatted timestamp of when the invoice was created."}},"links":[{"title":"List","description":"List invoices","href":"/invoices","method":"GET","rel":"instances","response_example":"invoices#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show an invoice","href":"/invoices/{(%2Fdefinitions%2Finvoices%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"invoices#show","targetSchema":{"$ref":"#/definitions/invoices/"}},{"title":"Create","description":"Create an invoice","href":"/invoices","method":"POST","rel":"create","response_example":"invoices#create","targetSchema":{"$ref":"#/definitions/invoices/"},"schema":{"type":["object"],"properties":{"customer":{"$ref":"#/definitions/customers/definitions/id"},"metadata":{"$ref":"#/definitions/subscriptions/definitions/metadata"}},"required":["customer"]}},{"title":"Preview","description":"Preview an upcoming invoice","href":"/invoices/preview","method":"GET","rel":"self","response_example":"invoices#preview","targetSchema":{"$ref":"#/definitions/invoices/"},"schema":{"type":["object"],"properties":{"subscription":{"$ref":"#/definitions/invoices/properties/subscription"}},"required":["subscription"]}}],"properties":{"id":{"$ref":"#/definitions/payments/definitions/id"},"resource":{"$ref":"#/definitions/invoices/definitions/resource"},"subscription":{"$ref":"#/definitions/subscriptions/definitions/id"},"paid":{"$ref":"#/definitions/invoices/definitions/paid"},"invoice_items":{"$ref":"#/definitions/list/"},"total":{"$ref":"#/definitions/payments/definitions/total"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"created_at":{"$ref":"#/definitions/invoices/definitions/created_at"}},"description":"Subscription Invoice","title":"Invoices"},"invoice_items":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"66a4824ac97cc7afff608f27c7","readOnly":true,"type":["string"],"description":"A unique identifier for the invoice items."},"resource":{"example":"invoice_item","readOnly":true,"enum":["invoice_item"],"description":"Name of resource"},"type":{"example":"invoice_item","readOnly":true,"enum":["invoice_item","plan"]},"plan":{"oneOf":[{"$ref":"#/definitions/plans/"},{"type":["null"]}]},"invoice":{"readOnly":true,"type":["string","null"]}},"links":[{"title":"List","description":"List invoice items","href":"/invoice_items","method":"GET","rel":"instances","response_example":"invoice_items#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show an invoice item","href":"/invoice_items/{(%2Fdefinitions%2Finvoice_items%2Fdefinitions%2Fid)}","method":"GET","rel":"self","response_example":"invoice_items#show","targetSchema":{"$ref":"#/definitions/invoice_items/"}},{"title":"Create","description":"Create an invoice item","href":"/invoice_items","method":"POST","rel":"create","response_example":"invoice_items#create","targetSchema":{"$ref":"#/definitions/invoice_items/"},"schema":{"type":["object"],"properties":{"amount":{"$ref":"#/definitions/invoice_items/properties/amount"},"currency":{"$ref":"#/definitions/invoice_items/properties/currency"},"customer":{"$ref":"#/definitions/invoice_items/properties/customer"},"metadata":{"$ref":"#/definitions/invoice_items/properties/metadata"}},"required":["amount","currency","customer"]}},{"title":"Destroy","description":"Deletes an invoice item from the upcoming invoice.","href":"/invoice_items/{(%2Fdefinitions%2Finvoice_items%2Fdefinitions%2Fid)}","method":"DELETE","rel":"destroy","response_example":"invoice_items#destroy","targetSchema":{"$ref":"#/definitions/invoice_items/"}}],"properties":{"id":{"$ref":"#/definitions/payments/definitions/id"},"resource":{"$ref":"#/definitions/invoice_items/definitions/resource"},"type":{"$ref":"#/definitions/invoice_items/definitions/type"},"amount":{"$ref":"#/definitions/payments/definitions/amount"},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"customer":{"$ref":"#/definitions/customers/definitions/id"},"invoice":{"$ref":"#/definitions/invoice_items/definitions/invoice"},"plan":{"$ref":"#/definitions/invoice_items/definitions/plan"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"}},"required":["id","resource","type","amount","customer","currency","invoice","metadata","plan"],"description":"Subscription Invoice Items","title":"Invoice Items"},"plans":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"name":{"example":"name2","type":["string"],"description":"Name of the plan."},"resource":{"example":"plan","enum":["plan"],"description":"Name of resource"},"interval":{"example":"month","enum":["day","week","month","year"],"description":"The billing frequency of a subscription."},"interval_count":{"example":"1","type":["integer"],"minimum":1,"description":"The number of intervals before the end of each billing period. For example, `interval=month` and `interval_count=3` would bill every 3 months."},"amount":{"$ref":"#/definitions/payments/definitions/amount"},"tax_percent":{"type":["integer","null"]},"currency":{"$ref":"#/definitions/payments/definitions/currency"},"metadata":{"$ref":"#/definitions/payments/definitions/metadata"},"renewal_notice_days":{"example":1,"type":["integer"],"minimum":0},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","readOnly":true,"type":["string"],"description":"An ISO 8601 formatted timestamp of when the plan was created."}},"links":[{"title":"List","description":"List plans","href":"/plans","method":"GET","rel":"instances","response_example":"plans#index","targetSchema":{"$ref":"#/definitions/list/"}},{"title":"Show","description":"Show a plan","href":"/plans/{(%2Fdefinitions%2Fplans%2Fdefinitions%2Fname)}","method":"GET","rel":"self","response_example":"plans#show","targetSchema":{"$ref":"#/definitions/plans/"}},{"title":"Create","description":"Create a plan","href":"/plans","method":"POST","rel":"create","response_example":"plans#create","targetSchema":{"$ref":"#/definitions/plans/"},"schema":{"type":["object"],"properties":{"name":{"$ref":"#/definitions/plans/definitions/name"},"interval":{"$ref":"#/definitions/plans/definitions/interval"},"interval_count":{"$ref":"#/definitions/plans/definitions/interval_count"},"amount":{"$ref":"#/definitions/plans/definitions/amount"},"tax_percent":{"$ref":"#/definitions/plans/definitions/tax_percent"},"currency":{"$ref":"#/definitions/plans/definitions/currency"},"renewal_notice_days":{"$ref":"#/definitions/plans/definitions/renewal_notice_days"},"metadata":{"$ref":"#/definitions/plans/definitions/metadata"}},"required":["name","interval","amount","currency"]}},{"title":"Destroy","description":"Destroy a plan","href":"/plans/{(%2Fdefinitions%2Fplans%2Fdefinitions%2Fname)}","method":"DELETE","rel":"destroy","response_example":"plans#destroy","targetSchema":{"$ref":"#/definitions/plans/"}}],"properties":{"resource":{"$ref":"#/definitions/plans/definitions/resource"},"name":{"$ref":"#/definitions/plans/definitions/name"},"interval":{"$ref":"#/definitions/plans/definitions/interval"},"interval_count":{"$ref":"#/definitions/plans/definitions/interval_count"},"currency":{"$ref":"#/definitions/plans/definitions/currency"},"amount":{"$ref":"#/definitions/plans/definitions/amount"},"tax_percent":{"$ref":"#/definitions/plans/definitions/tax_percent"},"renewal_notice_days":{"$ref":"#/definitions/plans/definitions/renewal_notice_days"},"metadata":{"$ref":"#/definitions/plans/definitions/metadata"},"created_at":{"$ref":"#/definitions/plans/definitions/created_at"}},"description":"Subscription Plans","title":"Plans"},"tokens":{"$schema":"http://json-schema.org/draft-04/hyper-schema","type":["object"],"definitions":{"id":{"example":"tok_ed4119a0f69bc365286d5a9a8777f33cee024f19d532454e6abffccc42cf1452b6ad214de6b8e876cabc60ae6f","readOnly":true,"type":["string"],"description":"A unique identifier for the token."},"resource":{"example":"token","enum":["token"],"description":"Name of resource"},"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_response"},"created_at":{"example":"2015-03-06T06:52:35Z","format":"date-time","type":["string"],"description":"An ISO 8601 formatted timestamp of when the token was created."}},"links":[{"title":"Create","description":"Create a token","href":"/tokens","method":"POST","rel":"create","response_example":"tokens#create","targetSchema":{"$ref":"#/definitions/list/"},"schema":{"type":["object"],"properties":{"payment_details":{"$ref":"#/definitions/payments/definitions/payment_details_request"}},"required":["payment_details"],"additionalFields":false}}],"properties":{"id":{"$ref":"#/definitions/tokens/definitions/id"},"resource":{"$ref":"#/definitions/tokens/definitions/resource"},"created_at":{"$ref":"#/definitions/tokens/definitions/created_at"}},"description":"Token resource","title":"Tokens"}},"properties":{"events":{"$ref":"#/definitions/events"},"payments":{"$ref":"#/definitions/payments"},"payouts":{"$ref":"#/definitions/payouts"},"subscriptions":{"$ref":"#/definitions/subscriptions"},"customers":{"$ref":"#/definitions/customers"},"invoices":{"$ref":"#/definitions/invoices"},"invoice_items":{"$ref":"#/definitions/invoice_items"},"plans":{"$ref":"#/definitions/plans"},"tokens":{"$ref":"#/definitions/tokens"}},"type":["object"],"id":"komoju","links":[{"href":"https://komoju.com/api/v1","rel":"self"}],"description":"Komoju API auto-generated JSON Schema","title":"Komoju API"}
459
+ HEROICS_SCHEMA
460
+ end
@@ -1,3 +1,3 @@
1
1
  module Komoju
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/komoju.rb CHANGED
@@ -1,5 +1,13 @@
1
- require "komoju/version"
1
+ require 'komoju/version'
2
+ require 'komoju/client'
2
3
 
3
4
  module Komoju
4
- # Your code goes here...
5
+ def self.connect(api_key, options=nil)
6
+ options = custom_options(options)
7
+ uri = URI.parse(options[:url])
8
+ uri.user = api_key
9
+ uri.password = ""
10
+ client = Heroics.client_from_schema(SCHEMA, uri.to_s, options)
11
+ Client.new(client)
12
+ end
5
13
  end
@@ -0,0 +1,8 @@
1
+ require 'helper'
2
+
3
+ class ClientTest < MiniTest::Unit::TestCase
4
+ def test_client
5
+ client = Komoju.connect("api-key", url: "https://api.komoju.com")
6
+ assert_equal(client.class, Komoju::Client)
7
+ end
8
+ end
data/test/helper.rb ADDED
@@ -0,0 +1 @@
1
+ require 'komoju'