chartmogul-ruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -7
  3. data/changelog.md +2 -0
  4. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/adds_custom_attributes.yml +7 -7
  5. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/adds_required_tags.yml +6 -6
  6. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/removes_custom_attributes.yml +6 -6
  7. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/removes_tags.yml +6 -6
  8. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml +2 -2
  9. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml +3 -3
  10. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml +3 -3
  11. data/fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/updates_custom_attributes.yml +2 -2
  12. data/fixtures/vcr_cassettes/ChartMogul_Import_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml +102 -0
  13. data/fixtures/vcr_cassettes/ChartMogul_Import_Customer/_find_by_external_id/when_external_id_is_provided/returns_nil_if_customer_does_not_exist.yml +101 -0
  14. data/lib/chartmogul/api/actions/custom.rb +1 -1
  15. data/lib/chartmogul/enrichment/customer.rb +7 -7
  16. data/lib/chartmogul/import/customer.rb +8 -5
  17. data/lib/chartmogul/import/customer_invoices.rb +4 -0
  18. data/lib/chartmogul/import/subscription.rb +4 -1
  19. data/lib/chartmogul/metrics/activity.rb +6 -4
  20. data/lib/chartmogul/metrics/subscription.rb +6 -4
  21. data/lib/chartmogul/version.rb +1 -1
  22. metadata +4 -4
  23. data/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +0 -40
  24. data/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 529dca739484aeb6a86eda45196b8857bbae7097
4
- data.tar.gz: 537fbba48ed5ecb97d90ffc90959d83d146fb221
3
+ metadata.gz: 6b859eeac7039565d7e50ea0d9c147e286d6572b
4
+ data.tar.gz: def526626d2ce227a765ff2be1be324155c72d1c
5
5
  SHA512:
6
- metadata.gz: 8738197ba9ec6dce2964f6723217704caca2e683e4ce01aa412bdf57a5846ed57f88456e8f878a2d872e420530091ffbe2406034afa53ef8b952ca1db9f55a11
7
- data.tar.gz: e4f44ace64b2165416f9652f2cca000046683d61ae00b69fa121817fe18b50a69670d064ef6c784c2bc94d0679118c1e1d90438cad7c443b7b6aac44e7f79c05
6
+ metadata.gz: 9d2df64aabb7b5d079294078bb3a753e1c168dd0aced4bbcebd432650478d70984466eb7fb7581ecdd6211ee12e46bd02acb313d5e99e4224bfc06d0210aaf75
7
+ data.tar.gz: af91fe7fe6a0bdb15a241398150094f002d8b0001a2d172750e2bfccdb09f5c50ba3335c0690420c5e72856d80e9a8c5589f21d84b6789aa4ddf04da511cac88
data/README.md CHANGED
@@ -6,17 +6,20 @@
6
6
 
7
7
  <p align="center"><code>chartmogul-ruby</code> provides convenient Ruby bindings for <a href="https://dev.chartmogul.com">ChartMogul's API</a>.</p>
8
8
 
9
- <p align="center"><img src="https://travis-ci.com/chartmogul/chartmogul-ruby.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master"></p>
9
+ <p align="center">
10
+ <a href="https://badge.fury.io/rb/chartmogul-ruby"><img src="https://badge.fury.io/rb/chartmogul-ruby.svg" alt="Gem Version"></a>
11
+ <a href="https://travis-ci.org/chartmogul/chartmogul-ruby"><img src="https://travis-ci.org/chartmogul/chartmogul-ruby.svg?branch=master" alt="Travis project"></a>
12
+ </p>
10
13
 
11
14
  <hr>
12
15
 
13
16
  <p align="center">
14
17
  <b><a href="#installation">Installation</a></b>
15
18
  |
16
- <b><a href="#usage">Usage</a></b>
17
- |
18
19
  <b><a href="#configuration">Configuration</a></b>
19
20
  |
21
+ <b><a href="#usage">Usage</a></b>
22
+ |
20
23
  <b><a href="#development">Development</a></b>
21
24
  |
22
25
  <b><a href="#contributing">Contributing</a></b>
@@ -44,10 +47,6 @@ Or install it yourself as:
44
47
 
45
48
  $ gem install chartmogul-ruby
46
49
 
47
- ## Usage
48
-
49
- See ChartMogul's [API documentation](https://dev.chartmogul.com).
50
-
51
50
  ## Configuration
52
51
 
53
52
  Configure `chartmogul-ruby` with your Account Token and Secret Key, available from the administration section of your ChartMogul account.
@@ -57,6 +56,31 @@ ChartMogul.account_token = '<Account key goes here>'
57
56
  ChartMogul.secret_key = '<Secret key goes here>'
58
57
  ```
59
58
 
59
+ ## Usage
60
+
61
+ For example, to create a Data Source object,
62
+
63
+ Request:
64
+ ```ruby
65
+ ChartMogul::Import::DataSource.create!(
66
+ name: 'In-house billing'
67
+ )
68
+ ```
69
+
70
+ Response:
71
+ ```ruby
72
+ #<ChartMogul::Import::DataSource:0x007ff9f127d628
73
+ @name="In-house billing",
74
+ @uuid="ds_cfc2b8f2-ad2c-4e3d-b64f-58d0bb282824",
75
+ @status="never_imported",
76
+ @created_at=2016-06-27 11:27:37 UTC
77
+ >
78
+ ```
79
+
80
+ You can find examples for each endpoint in the ChartMogul [API documentation](https://dev.chartmogul.com/).
81
+
82
+ [![https://gyazo.com/f7a2a1b86a409586ee8dd0f4f7563937](https://i.gyazo.com/f7a2a1b86a409586ee8dd0f4f7563937.gif)](https://i.gyazo.com/f7a2a1b86a409586ee8dd0f4f7563937.gif)
83
+
60
84
  ## Development
61
85
 
62
86
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/changelog.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # chartmogul-ruby Change Log
2
2
 
3
+ ## Version 0.1.2 - 13 July 2016
4
+ - Fix bug preventing cancellation of subscriptions [#22]
3
5
 
4
6
  ## Version 0.1.1 - 4 July 2016
5
7
  - Version bump after 0.1.0 pushed to RubyGems under incorrect account.
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -36,12 +36,12 @@ http_interactions:
36
36
  encoding: UTF-8
37
37
  string: '{"id":20268060,"uuid":"cus_07393ece-aab1-4255-8bcd-0ef11e24b047","external_id":"cus_0001","name":"Adam
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":["example","another-tag"]},"address":{"country":"United
39
- States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
40
- http_version:
39
+ States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
40
+ http_version:
41
41
  recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
42
42
  - request:
43
43
  method: post
44
- uri: https://api.chartmogul.com/v1/customers/20268060/attributes/custom
44
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/custom
45
45
  body:
46
46
  encoding: UTF-8
47
47
  string: '{"custom":[{"type":"String","key":"string_key","value":"String Value"},{"type":"Integer","key":"integer_key","value":1234},{"type":"Timestamp","key":"timestamp_key","value":"2016-01-31
@@ -56,7 +56,7 @@ http_interactions:
56
56
  response:
57
57
  status:
58
58
  code: 200
59
- message:
59
+ message:
60
60
  headers:
61
61
  server:
62
62
  - nginx/1.9.10
@@ -75,6 +75,6 @@ http_interactions:
75
75
  body:
76
76
  encoding: UTF-8
77
77
  string: '{"custom":{"string_key":"String Value","integer_key":1234,"timestamp_key":"2016-01-31T00:00:00.000Z","boolean_key":true}}'
78
- http_version:
78
+ http_version:
79
79
  recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
80
80
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -37,11 +37,11 @@ http_interactions:
37
37
  string: '{"id":20268060,"uuid":"cus_07393ece-aab1-4255-8bcd-0ef11e24b047","external_id":"cus_0001","name":"Adam
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":[]},"address":{"country":"United
39
39
  States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
40
- http_version:
40
+ http_version:
41
41
  recorded_at: Wed, 29 Jun 2016 12:47:08 GMT
42
42
  - request:
43
43
  method: post
44
- uri: https://api.chartmogul.com/v1/customers/20268060/attributes/tags
44
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/tags
45
45
  body:
46
46
  encoding: UTF-8
47
47
  string: '{"tags":["example","another-tag"]}'
@@ -55,7 +55,7 @@ http_interactions:
55
55
  response:
56
56
  status:
57
57
  code: 200
58
- message:
58
+ message:
59
59
  headers:
60
60
  server:
61
61
  - nginx/1.9.10
@@ -74,6 +74,6 @@ http_interactions:
74
74
  body:
75
75
  encoding: UTF-8
76
76
  string: '{"tags":["example","another-tag"]}'
77
- http_version:
77
+ http_version:
78
78
  recorded_at: Wed, 29 Jun 2016 12:47:08 GMT
79
79
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -38,11 +38,11 @@ http_interactions:
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":["another-tag"],"custom":{"string_key":"Another
39
39
  String Value","integer_key":"5678","timestamp_key":"2016-02-01 00:00:00 UTC","boolean_key":"f"}},"address":{"country":"United
40
40
  States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
41
- http_version:
41
+ http_version:
42
42
  recorded_at: Wed, 29 Jun 2016 13:57:20 GMT
43
43
  - request:
44
44
  method: delete
45
- uri: https://api.chartmogul.com/v1/customers/20268060/attributes/custom
45
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/custom
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: '{"custom":["string_key","integer_key","timestamp_key","boolean_key"]}'
@@ -56,7 +56,7 @@ http_interactions:
56
56
  response:
57
57
  status:
58
58
  code: 200
59
- message:
59
+ message:
60
60
  headers:
61
61
  server:
62
62
  - nginx/1.9.10
@@ -75,6 +75,6 @@ http_interactions:
75
75
  body:
76
76
  encoding: UTF-8
77
77
  string: '{}'
78
- http_version:
78
+ http_version:
79
79
  recorded_at: Wed, 29 Jun 2016 13:57:20 GMT
80
80
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -38,11 +38,11 @@ http_interactions:
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":["example","another-tag"],"custom":{"string_key":"Another
39
39
  String Value","integer_key":"5678","timestamp_key":"2016-02-01 00:00:00 UTC","boolean_key":"f"}},"address":{"country":"United
40
40
  States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
41
- http_version:
41
+ http_version:
42
42
  recorded_at: Wed, 29 Jun 2016 12:47:10 GMT
43
43
  - request:
44
44
  method: delete
45
- uri: https://api.chartmogul.com/v1/customers/20268060/attributes/tags
45
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/tags
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: '{"tags":["example"]}'
@@ -56,7 +56,7 @@ http_interactions:
56
56
  response:
57
57
  status:
58
58
  code: 200
59
- message:
59
+ message:
60
60
  headers:
61
61
  server:
62
62
  - nginx/1.9.10
@@ -75,6 +75,6 @@ http_interactions:
75
75
  body:
76
76
  encoding: UTF-8
77
77
  string: '{"tags":["another-tag"]}'
78
- http_version:
78
+ http_version:
79
79
  recorded_at: Wed, 29 Jun 2016 12:47:11 GMT
80
80
  recorded_with: VCR 3.0.3
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -42,6 +42,6 @@ http_interactions:
42
42
  States","state":null,"city":"San Francisco","address_line1":null,"address_line2":null,"address_zip":""},"mrr":7500,"arr":90000,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20286023-Zuora_Customer","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"},{"id":20268060,"uuid":"cus_07393ece-aab1-4255-8bcd-0ef11e24b047","external_id":"cus_0001","name":"Adam
43
43
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":[]},"address":{"country":"United
44
44
  States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}],"has_more":false,"per_page":10,"page":1}'
45
- http_version:
45
+ http_version:
46
46
  recorded_at: Wed, 29 Jun 2016 12:45:27 GMT
47
47
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -37,6 +37,6 @@ http_interactions:
37
37
  string: '{"id":20268060,"uuid":"cus_07393ece-aab1-4255-8bcd-0ef11e24b047","external_id":"cus_0001","name":"Adam
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":[]},"address":{"country":"United
39
39
  States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}'
40
- http_version:
40
+ http_version:
41
41
  recorded_at: Wed, 29 Jun 2016 12:47:08 GMT
42
42
  recorded_with: VCR 3.0.3
@@ -16,7 +16,7 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message:
20
20
  headers:
21
21
  server:
22
22
  - nginx/1.9.10
@@ -37,7 +37,7 @@ http_interactions:
37
37
  string: '{"entries":[{"id":20268060,"uuid":"cus_07393ece-aab1-4255-8bcd-0ef11e24b047","external_id":"cus_0001","name":"Adam
38
38
  Smith","email":"adam@smith.com","status":"Cancelled","customer-since":"2016-05-01T12:00:00+00:00","attributes":{"tags":["another-tag"],"custom":{"string_key":"Another
39
39
  String Value","integer_key":"5678","timestamp_key":"2016-02-01 00:00:00 UTC","boolean_key":"f"}},"address":{"country":"United
40
- States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/20268060-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}],"has_more":false,"per_page":200,"page":1}'
41
- http_version:
40
+ States","state":null,"city":"New York","address_line1":null,"address_line2":null,"address_zip":""},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047-Adam_Smith","billing-system-type":"ImportApi","currency":"USD","currency-sign":"$"}],"has_more":false,"per_page":200,"page":1}'
41
+ http_version:
42
42
  recorded_at: Wed, 29 Jun 2016 12:47:11 GMT
43
43
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/20268060
5
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: '{}'
@@ -42,7 +42,7 @@ http_interactions:
42
42
  recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
43
43
  - request:
44
44
  method: put
45
- uri: https://api.chartmogul.com/v1/customers/20268060/attributes/custom
45
+ uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/custom
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: '{"custom":{"string_key":"Another String Value","integer_key":5678,"timestamp_key":"2016-02-01
@@ -0,0 +1,102 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.chartmogul.com/v1/import/customers
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data_source_uuid":"ds_154b9620-a22a-478a-8b44-198d11cc9a85","external_id":"X1234","name":"Test
9
+ Customer","email":"test@example.com","company":null,"country":"DE","state":null,"city":"Berlin","zip":null}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.9.1
13
+ Content-Type:
14
+ - application/json
15
+ Authorization:
16
+ - Basic ODE2MjZkMWFiMzU5NTIwMzY5MjhjNjJjYmJiNDMyN2M6ODY3MDRmMDdkYzQwZmYzYjYyYzRjY2E5OTYxMjk2MzY=
17
+ response:
18
+ status:
19
+ code: 201
20
+ message:
21
+ headers:
22
+ server:
23
+ - nginx/1.9.10
24
+ date:
25
+ - Mon, 06 Jun 2016 15:26:39 GMT
26
+ content-type:
27
+ - application/json; charset=utf-8
28
+ transfer-encoding:
29
+ - chunked
30
+ connection:
31
+ - close
32
+ x-frame-options:
33
+ - SAMEORIGIN
34
+ x-xss-protection:
35
+ - 1; mode=block
36
+ x-content-type-options:
37
+ - nosniff
38
+ etag:
39
+ - W/"2bb61213c73b74bf7e3094b3a2814b1c"
40
+ cache-control:
41
+ - max-age=0, private, must-revalidate
42
+ x-request-id:
43
+ - 7a43eb0b-0099-4cef-b620-a6ac687ace2f
44
+ x-runtime:
45
+ - '0.202425'
46
+ strict-transport-security:
47
+ - max-age=15768000
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"uuid":"cus_c4babf63-3eb9-4125-8687-2a0d781b0af2","external_id":"X1234","name":"Test
51
+ Customer","company":"","email":"test@example.com","city":"Berlin","state":"","country":"DE","zip":"","data_source_uuid":"ds_154b9620-a22a-478a-8b44-198d11cc9a85"}'
52
+ http_version:
53
+ recorded_at: Mon, 06 Jun 2016 15:26:39 GMT
54
+ - request:
55
+ method: get
56
+ uri: https://api.chartmogul.com/v1/import/customers?external_id=X1234
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ User-Agent:
62
+ - Faraday v0.9.1
63
+ Authorization:
64
+ - Basic ODE2MjZkMWFiMzU5NTIwMzY5MjhjNjJjYmJiNDMyN2M6ODY3MDRmMDdkYzQwZmYzYjYyYzRjY2E5OTYxMjk2MzY=
65
+ response:
66
+ status:
67
+ code: 200
68
+ message:
69
+ headers:
70
+ server:
71
+ - nginx/1.9.10
72
+ date:
73
+ - Mon, 06 Jun 2016 15:26:40 GMT
74
+ content-type:
75
+ - application/json; charset=utf-8
76
+ transfer-encoding:
77
+ - chunked
78
+ connection:
79
+ - close
80
+ x-frame-options:
81
+ - SAMEORIGIN
82
+ x-xss-protection:
83
+ - 1; mode=block
84
+ x-content-type-options:
85
+ - nosniff
86
+ etag:
87
+ - W/"f8b194be146b71827424808d2de63994"
88
+ cache-control:
89
+ - max-age=0, private, must-revalidate
90
+ x-request-id:
91
+ - aa0a64af-9cd4-4b7d-9d43-d3b7c08ac7d1
92
+ x-runtime:
93
+ - '0.020597'
94
+ strict-transport-security:
95
+ - max-age=15768000
96
+ body:
97
+ encoding: UTF-8
98
+ string: '{"customers":[{"uuid":"cus_c4babf63-3eb9-4125-8687-2a0d781b0af2","external_id":"X1234","name":"Test
99
+ Customer","company":"","email":"test@example.com","city":"Berlin","state":"","country":"DE","zip":"","data_source_uuid":"ds_154b9620-a22a-478a-8b44-198d11cc9a85"}],"current_page":1,"total_pages":1}'
100
+ http_version:
101
+ recorded_at: Mon, 06 Jun 2016 15:26:40 GMT
102
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.chartmogul.com/v1/import/customers
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"data_source_uuid":"ds_154b9620-a22a-478a-8b44-198d11cc9a85","external_id":"X1234","name":"Test
9
+ Customer","email":"test@example.com","company":null,"country":"DE","state":null,"city":"Berlin","zip":null}'
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.9.1
13
+ Content-Type:
14
+ - application/json
15
+ Authorization:
16
+ - Basic ODE2MjZkMWFiMzU5NTIwMzY5MjhjNjJjYmJiNDMyN2M6ODY3MDRmMDdkYzQwZmYzYjYyYzRjY2E5OTYxMjk2MzY=
17
+ response:
18
+ status:
19
+ code: 201
20
+ message:
21
+ headers:
22
+ server:
23
+ - nginx/1.9.10
24
+ date:
25
+ - Mon, 06 Jun 2016 15:26:39 GMT
26
+ content-type:
27
+ - application/json; charset=utf-8
28
+ transfer-encoding:
29
+ - chunked
30
+ connection:
31
+ - close
32
+ x-frame-options:
33
+ - SAMEORIGIN
34
+ x-xss-protection:
35
+ - 1; mode=block
36
+ x-content-type-options:
37
+ - nosniff
38
+ etag:
39
+ - W/"2bb61213c73b74bf7e3094b3a2814b1c"
40
+ cache-control:
41
+ - max-age=0, private, must-revalidate
42
+ x-request-id:
43
+ - 7a43eb0b-0099-4cef-b620-a6ac687ace2f
44
+ x-runtime:
45
+ - '0.202425'
46
+ strict-transport-security:
47
+ - max-age=15768000
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"uuid":"cus_c4babf63-3eb9-4125-8687-2a0d781b0af2","external_id":"X1234","name":"Test
51
+ Customer","company":"","email":"test@example.com","city":"Berlin","state":"","country":"DE","zip":"","data_source_uuid":"ds_154b9620-a22a-478a-8b44-198d11cc9a85"}'
52
+ http_version:
53
+ recorded_at: Mon, 06 Jun 2016 15:26:39 GMT
54
+ - request:
55
+ method: get
56
+ uri: https://api.chartmogul.com/v1/import/customers?external_id=nope
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ''
60
+ headers:
61
+ User-Agent:
62
+ - Faraday v0.9.1
63
+ Authorization:
64
+ - Basic ODE2MjZkMWFiMzU5NTIwMzY5MjhjNjJjYmJiNDMyN2M6ODY3MDRmMDdkYzQwZmYzYjYyYzRjY2E5OTYxMjk2MzY=
65
+ response:
66
+ status:
67
+ code: 200
68
+ message:
69
+ headers:
70
+ server:
71
+ - nginx/1.9.10
72
+ date:
73
+ - Mon, 06 Jun 2016 15:26:40 GMT
74
+ content-type:
75
+ - application/json; charset=utf-8
76
+ transfer-encoding:
77
+ - chunked
78
+ connection:
79
+ - close
80
+ x-frame-options:
81
+ - SAMEORIGIN
82
+ x-xss-protection:
83
+ - 1; mode=block
84
+ x-content-type-options:
85
+ - nosniff
86
+ etag:
87
+ - W/"f8b194be146b71827424808d2de63994"
88
+ cache-control:
89
+ - max-age=0, private, must-revalidate
90
+ x-request-id:
91
+ - aa0a64af-9cd4-4b7d-9d43-d3b7c08ac7d1
92
+ x-runtime:
93
+ - '0.020597'
94
+ strict-transport-security:
95
+ - max-age=15768000
96
+ body:
97
+ encoding: UTF-8
98
+ string: '{"customers":[]}'
99
+ http_version:
100
+ recorded_at: Mon, 06 Jun 2016 15:26:40 GMT
101
+ recorded_with: VCR 3.0.3
@@ -11,7 +11,7 @@ module ChartMogul
11
11
  end
12
12
 
13
13
  def custom!(http_method, http_path, body_data = {})
14
- json = custom_without_assign!(http_method, http_path, body_data = {})
14
+ json = custom_without_assign!(http_method, http_path, body_data)
15
15
  assign_all_attributes(json)
16
16
  end
17
17
 
@@ -32,36 +32,36 @@ module ChartMogul
32
32
 
33
33
  def add_tags!(*tags)
34
34
  self.tags = custom_without_assign!(:post,
35
- "/v1/customers/#{id}/attributes/tags",
35
+ "/v1/customers/#{uuid}/attributes/tags",
36
36
  tags: tags)[:tags]
37
37
  end
38
38
 
39
39
  def remove_tags!(*tags)
40
40
  self.tags = custom_without_assign!(:delete,
41
- "/v1/customers/#{id}/attributes/tags",
41
+ "/v1/customers/#{uuid}/attributes/tags",
42
42
  tags: tags)[:tags]
43
43
  end
44
44
 
45
45
  def add_custom_attributes!(*custom_attrs)
46
46
  self.custom_attributes = custom_without_assign!(:post,
47
- "/v1/customers/#{id}/attributes/custom",
47
+ "/v1/customers/#{uuid}/attributes/custom",
48
48
  custom: custom_attrs)[:custom]
49
49
  end
50
50
 
51
51
  def update_custom_attributes!(custom_attrs = {})
52
52
  self.custom_attributes = custom_without_assign!(:put,
53
- "/v1/customers/#{id}/attributes/custom",
53
+ "/v1/customers/#{uuid}/attributes/custom",
54
54
  custom: custom_attrs)[:custom]
55
55
  end
56
56
 
57
57
  def remove_custom_attributes!(*custom_attrs)
58
58
  self.custom_attributes = custom_without_assign!(:delete,
59
- "/v1/customers/#{id}/attributes/custom",
59
+ "/v1/customers/#{uuid}/attributes/custom",
60
60
  custom: custom_attrs)[:custom]
61
61
  end
62
62
 
63
- def self.retrieve(customer_id)
64
- custom!(:get, "/v1/customers/#{customer_id}")
63
+ def self.retrieve(uuid)
64
+ custom!(:get, "/v1/customers/#{uuid}")
65
65
  end
66
66
 
67
67
  def self.all(options = {})
@@ -15,19 +15,22 @@ module ChartMogul
15
15
  writeable_attr :state
16
16
  writeable_attr :city
17
17
  writeable_attr :zip
18
-
19
18
  writeable_attr :data_source_uuid
20
19
 
21
20
  include API::Actions::All
22
21
  include API::Actions::Create
23
22
  include API::Actions::Destroy
24
23
 
25
- def subscriptions
26
- @subscriptions ||= Subscription.all(customer_uuid: uuid)
24
+ def self.find_by_external_id(external_id)
25
+ all(external_id: external_id).first
26
+ end
27
+
28
+ def subscriptions(options = {})
29
+ @subscriptions ||= Subscription.all(uuid, options)
27
30
  end
28
31
 
29
- def invoices
30
- @invoices ||= CustomerInvoices.all(customer_uuid: uuid)
32
+ def invoices(options = {})
33
+ @invoices ||= CustomerInvoices.all(uuid, options)
31
34
  end
32
35
 
33
36
  def invoices=(invoices_array)
@@ -20,6 +20,10 @@ module ChartMogul
20
20
  map(&:serialize_for_write)
21
21
  end
22
22
 
23
+ def self.all(customer_uuid, options = {})
24
+ super(options.merge(customer_uuid: customer_uuid))
25
+ end
26
+
23
27
  def_delegators :invoices, :each, :[], :<<, :size, :length
24
28
 
25
29
  private
@@ -11,7 +11,6 @@ module ChartMogul
11
11
 
12
12
  readonly_attr :plan_uuid
13
13
  readonly_attr :data_source_uuid
14
- writeable_attr :customer_uuid
15
14
 
16
15
  include API::Actions::All
17
16
  include API::Actions::Custom
@@ -25,6 +24,10 @@ module ChartMogul
25
24
  def cancel(cancelled_at)
26
25
  custom!(:patch, "/v1/import/subscriptions/#{uuid}", cancelled_at: cancelled_at)
27
26
  end
27
+
28
+ def self.all(customer_uuid, options = {})
29
+ super(options.merge(customer_uuid: customer_uuid))
30
+ end
28
31
  end
29
32
  end
30
33
  end
@@ -11,8 +11,8 @@ module ChartMogul
11
11
  readonly_attr :currency
12
12
  readonly_attr :currency_sign
13
13
 
14
- def self.all(options = {})
15
- ChartMogul::Metrics::Activities.all(options)
14
+ def self.all(customer_uuid, options = {})
15
+ ChartMogul::Metrics::Activities.all(customer_uuid, options)
16
16
  end
17
17
  end
18
18
 
@@ -20,12 +20,14 @@ module ChartMogul
20
20
  set_resource_name 'Activities'
21
21
  set_resource_path '/v1/customers/:customer_uuid/activities'
22
22
 
23
- writeable_attr :customer_uuid
24
-
25
23
  include Concerns::Entries
26
24
  include Concerns::Pageable
27
25
 
28
26
  set_entry_class Activity
27
+
28
+ def self.all(customer_uuid, options = {})
29
+ super(options.merge(customer_uuid: customer_uuid))
30
+ end
29
31
  end
30
32
  end
31
33
  end
@@ -14,8 +14,8 @@ module ChartMogul
14
14
  readonly_attr :currency
15
15
  readonly_attr :currency_sign
16
16
 
17
- def self.all(options = {})
18
- ChartMogul::Metrics::Subscriptions.all(options)
17
+ def self.all(customer_uuid, options = {})
18
+ ChartMogul::Metrics::Subscriptions.all(customer_uuid, options)
19
19
  end
20
20
  end
21
21
 
@@ -23,12 +23,14 @@ module ChartMogul
23
23
  set_resource_name 'Subscriptions'
24
24
  set_resource_path '/v1/customers/:customer_uuid/subscriptions'
25
25
 
26
- writeable_attr :customer_uuid
27
-
28
26
  include Concerns::Entries
29
27
  include Concerns::Pageable
30
28
 
31
29
  set_entry_class Subscription
30
+
31
+ def self.all(customer_uuid, options = {})
32
+ super(options.merge(customer_uuid: customer_uuid))
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -1,3 +1,3 @@
1
1
  module ChartMogul
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartmogul-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Langenauer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-04 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -104,8 +104,6 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
- - ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
108
- - ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml
109
107
  - Gemfile
110
108
  - LICENSE.txt
111
109
  - README.md
@@ -128,6 +126,8 @@ files:
128
126
  - fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/updates_custom_attributes.yml
129
127
  - fixtures/vcr_cassettes/ChartMogul_Import_Customer/API_Interactions/correctly_handles_a_422_response.yml
130
128
  - fixtures/vcr_cassettes/ChartMogul_Import_Customer/API_Interactions/correctly_interracts_with_the_API.yml
129
+ - fixtures/vcr_cassettes/ChartMogul_Import_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml
130
+ - fixtures/vcr_cassettes/ChartMogul_Import_Customer/_find_by_external_id/when_external_id_is_provided/returns_nil_if_customer_does_not_exist.yml
131
131
  - fixtures/vcr_cassettes/ChartMogul_Import_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml
132
132
  - fixtures/vcr_cassettes/ChartMogul_Import_DataSource/API_Interactions/correctly_interracts_with_the_API.yml
133
133
  - fixtures/vcr_cassettes/ChartMogul_Import_DataSource/API_Interactions/correctly_raises_errors_on_404.yml
@@ -1,40 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.chartmogul.com/v1/metrics/mrr-churn-rate?end-date=2015-02-01&start-date=2015-01-01
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.9.2
12
- Content-Type:
13
- - application/json
14
- Authorization:
15
- - Basic YzU0NjYwNDU5ZTMzODBkYzUyNmVhYjNiZjlhZGIyOGQ6N2MyMDEzOTYzZjQ2NGZiMmQ3ZjVjOTJkZDZiMjk2NDQ=
16
- response:
17
- status:
18
- code: 200
19
- message:
20
- headers:
21
- server:
22
- - nginx/1.9.10
23
- date:
24
- - Fri, 01 Jul 2016 14:47:45 GMT
25
- content-type:
26
- - application/json
27
- content-length:
28
- - '160'
29
- connection:
30
- - close
31
- status:
32
- - 200 OK
33
- access-control-allow-credentials:
34
- - 'true'
35
- body:
36
- encoding: UTF-8
37
- string: '{"entries":[{"date":"2015-01-31","mrr-churn-rate":0.0},{"date":"2015-02-01","mrr-churn-rate":0.0}],"summary":{"current":0,"previous":0,"percentage-change":0.0}}'
38
- http_version:
39
- recorded_at: Fri, 01 Jul 2016 14:47:45 GMT
40
- recorded_with: VCR 3.0.3
@@ -1,40 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.chartmogul.com/v1/metrics/mrr-churn-rate?end-date=2015-02-01&start-date=2015-01-01
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.9.2
12
- Content-Type:
13
- - application/json
14
- Authorization:
15
- - Basic YzU0NjYwNDU5ZTMzODBkYzUyNmVhYjNiZjlhZGIyOGQ6N2MyMDEzOTYzZjQ2NGZiMmQ3ZjVjOTJkZDZiMjk2NDQ=
16
- response:
17
- status:
18
- code: 200
19
- message:
20
- headers:
21
- server:
22
- - nginx/1.9.10
23
- date:
24
- - Fri, 01 Jul 2016 14:47:44 GMT
25
- content-type:
26
- - application/json
27
- content-length:
28
- - '160'
29
- connection:
30
- - close
31
- status:
32
- - 200 OK
33
- access-control-allow-credentials:
34
- - 'true'
35
- body:
36
- encoding: UTF-8
37
- string: '{"entries":[{"date":"2015-01-31","mrr-churn-rate":0.0},{"date":"2015-02-01","mrr-churn-rate":0.0}],"summary":{"current":0,"previous":0,"percentage-change":0.0}}'
38
- http_version:
39
- recorded_at: Fri, 01 Jul 2016 14:47:44 GMT
40
- recorded_with: VCR 3.0.3