chartmogul_client 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a086af54516adf8632da52a59d11cffe99358699
4
- data.tar.gz: e7bb8210daa809b122fb81b1126777cfec9ae437
3
+ metadata.gz: 26dbce9ba7e2cad8f4a591db47a9d92a537818fc
4
+ data.tar.gz: 18ecd770d6a39e4441cf37b3cd2920396e21ee38
5
5
  SHA512:
6
- metadata.gz: 2ef2be6f7435ebb4f9f092516a3d5cb4a17efba117ec9cf3d5898b1b91e92ea69febe30ccb6e4def912e749327e2bf6249158a6b54ae7c040c43524d69fd2b1a
7
- data.tar.gz: 9942371b93de9d5a75fca0f9419908b78fa8d308f0a2975b464c4abecde8be34d3ca5316191f271ef2567a6eb6a643899fbab647494d2431998dce31b36bd375
6
+ metadata.gz: f0c257273385233e62fc4c34913c3af5589313de92f38dfa665aea0fd1562c30a8c452893c3ea75be33b213ecda0ae20f55495d5149e619a1c5dbed1ecc8d60d
7
+ data.tar.gz: 3d81ecf17a60bfd5dd55a24e4ce81211efc12873054436e0377f8c4bde0efd8e64d54de7396b68202ffe137f96686fea5f12915f2f5b5c08e7996d476ffbf2ef
@@ -9,11 +9,57 @@ module Chartmogul
9
9
  #
10
10
  # customer_id - The String/Integer ChartMogul ID of the customer.
11
11
  # Specified as part of the URL.
12
- # options - The Hash options used to create a Invoices (default: {}).
12
+ # invoices - The Array options used to create a Invoices (default: []).
13
+ #
14
+ # Examples
15
+ #
16
+ # client.import.customers.invoices.create 'foo', [
17
+ # {
18
+ # "external_id": "INV0001",
19
+ # "date": "2015-11-01 00:00:00",
20
+ # "currency": "USD",
21
+ # "due_date": "2015-11-15 00:00:00",
22
+ # "line_items": [
23
+ # {
24
+ # "type": "subscription",
25
+ # "subscription_external_id": "sub_0001",
26
+ # "plan_uuid":"pl_eed05d54-75b4-431b-adb2-eb6b9e543206",
27
+ # "service_period_start": "2015-11-01 00:00:00",
28
+ # "service_period_end": "2015-12-01 00:00:00",
29
+ # "amount_in_cents": 5000,
30
+ # "quantity": 1,
31
+ # "discount_code": "PSO86",
32
+ # "discount_amount_in_cents": 1000,
33
+ # "tax_amount_in_cents": 900
34
+ # },
35
+ # {
36
+ # "type": "one_time",
37
+ # "description": "Setup Fees",
38
+ # "amount_in_cents": 2500,
39
+ # "quantity": 1,
40
+ # "discount_code": "PSO86",
41
+ # "discount_amount_in_cents": 500,
42
+ # "tax_amount_in_cents": 450
43
+ # }
44
+ # ],
45
+ # "transactions": [
46
+ # {
47
+ # "date": "2015-11-05 00:14:23",
48
+ # "type": "payment",
49
+ # "result": "successful"
50
+ # }
51
+ # ]
52
+ # }
53
+ # ]
13
54
  #
14
55
  # Returns the instance of Chartmogul::V1::Request.
15
- def create(customer_id, **options)
16
- Chartmogul::V1::Request.new "#{BASE_URI}/#{customer_id}/invoices", options.merge(method: :post, userpwd: client.userpwd)
56
+ def create(customer_id, invoices = [])
57
+ Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/invoices",
58
+ body: MultiJson.dump(invoices: invoices),
59
+ headers: { 'Content-Type' => 'application/json' },
60
+ method: :post,
61
+ userpwd: client.userpwd,
62
+ )
17
63
  end
18
64
 
19
65
  end
@@ -1,5 +1,5 @@
1
1
  module Chartmogul
2
2
 
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
 
5
5
  end
@@ -6,13 +6,14 @@ RSpec.describe Chartmogul::V1::Import::Invoices do
6
6
 
7
7
  describe '#create' do
8
8
  let(:url) { 'https://api.chartmogul.com/v1/import/customers/customer-id/invoices' }
9
- let(:query) { { foo: 'bar' } }
9
+ let(:body) { [ {foo: 'bar'} ] }
10
+ let(:query) { {} }
10
11
 
11
12
  before do
12
- stub_request(:post, url).with(query: query).to_return(status: 201)
13
+ stub_request(:post, url).with(body: { invoices: body }.to_json).to_return(status: 201)
13
14
  end
14
15
 
15
- subject { client.import.customers.invoices.create('customer-id', query) }
16
+ subject { client.import.customers.invoices.create('customer-id', body) }
16
17
 
17
18
  it_should_behave_like 'a base ChartMogul API V1 requests', method: :post
18
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartmogul_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vokhmin