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 +4 -4
- data/lib/chartmogul/v1/import/invoices.rb +49 -3
- data/lib/chartmogul/version.rb +1 -1
- data/spec/chartmogul/v1/import/invoices_spec.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26dbce9ba7e2cad8f4a591db47a9d92a537818fc
|
|
4
|
+
data.tar.gz: 18ecd770d6a39e4441cf37b3cd2920396e21ee38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
#
|
|
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,
|
|
16
|
-
Chartmogul::V1::Request.new
|
|
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
|
data/lib/chartmogul/version.rb
CHANGED
|
@@ -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(:
|
|
9
|
+
let(:body) { [ {foo: 'bar'} ] }
|
|
10
|
+
let(:query) { {} }
|
|
10
11
|
|
|
11
12
|
before do
|
|
12
|
-
stub_request(:post, url).with(
|
|
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',
|
|
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
|