chartmogul-ruby 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +3 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/adds_custom_attributes.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/adds_required_tags.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/merges_customers.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/raises_401_if_invalid_credentials.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/raises_404_if_no_customers_found.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/raises_422_for_update_with_invalid_data.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/removes_custom_attributes.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/removes_tags.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/returns_all_customers_through_list_all_endpoint.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/returns_customer_through_retrieve_endpoint.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/returns_right_customers_through_search_endpoint.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/updates_custom_attributes.yml +0 -0
- data/fixtures/vcr_cassettes/{ChartMogul_Enrichment_Customer → ChartMogul_Customer}/API_Interactions/updates_customer.yml +0 -0
- data/lib/chartmogul/customer.rb +101 -11
- data/lib/chartmogul/data_source.rb +1 -0
- data/lib/chartmogul/enrichment/customer.rb +11 -2
- data/lib/chartmogul/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af78d54ace12411026ce9ee9a25248f092428f2c
|
4
|
+
data.tar.gz: 4fd3512f3b39ee8df129f94cf2994f7cc0983fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b317b68430c609ba27240dd6fdd12f7ab92293b72d11dd45813e937af7d509e71ddc185d19964bf199be02433001a00dba04d4d4a6c9f95467c65fdf53b3a91
|
7
|
+
data.tar.gz: 60ef9540f2486f9ee9cad87a327df056e12c300a04e44a7051d04bfcf21e3e0e33a6d31be863e657f437abeb9c08db235b64aab1933654dbfd04266ded1438e0
|
data/changelog.md
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/chartmogul/customer.rb
CHANGED
@@ -4,7 +4,22 @@ module ChartMogul
|
|
4
4
|
set_resource_path '/v1/customers'
|
5
5
|
|
6
6
|
readonly_attr :uuid
|
7
|
+
readonly_attr :id
|
7
8
|
|
9
|
+
readonly_attr :status
|
10
|
+
readonly_attr :customer_since, type: :time
|
11
|
+
readonly_attr :address
|
12
|
+
readonly_attr :mrr
|
13
|
+
readonly_attr :arr
|
14
|
+
readonly_attr :billing_system_url
|
15
|
+
readonly_attr :chartmogul_url
|
16
|
+
readonly_attr :billing_system_type
|
17
|
+
readonly_attr :currency
|
18
|
+
readonly_attr :currency_sign
|
19
|
+
readonly_attr :data_source_uuids
|
20
|
+
readonly_attr :external_ids
|
21
|
+
|
22
|
+
writeable_attr :attributes
|
8
23
|
writeable_attr :external_id
|
9
24
|
writeable_attr :name
|
10
25
|
writeable_attr :email
|
@@ -18,12 +33,18 @@ module ChartMogul
|
|
18
33
|
writeable_attr :free_trial_started_at, type: :time
|
19
34
|
|
20
35
|
include API::Actions::Create
|
36
|
+
include API::Actions::Update
|
37
|
+
include API::Actions::Custom
|
21
38
|
include API::Actions::Destroy
|
22
39
|
|
23
40
|
def self.all(options = {})
|
24
41
|
Customers.all(options)
|
25
42
|
end
|
26
43
|
|
44
|
+
def self.retrieve(uuid)
|
45
|
+
custom!(:get, "/v1/customers/#{uuid}")
|
46
|
+
end
|
47
|
+
|
27
48
|
def self.search(email)
|
28
49
|
Customers.search(email)
|
29
50
|
end
|
@@ -44,22 +65,91 @@ module ChartMogul
|
|
44
65
|
@invoices = ChartMogul::CustomerInvoices.new(customer_uuid: uuid, invoices: invoices_array)
|
45
66
|
end
|
46
67
|
|
68
|
+
# Enrichment
|
69
|
+
def tags
|
70
|
+
@attributes[:tags]
|
71
|
+
end
|
72
|
+
|
73
|
+
def custom_attributes
|
74
|
+
@attributes[:custom]
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_tags!(*tags)
|
78
|
+
self.tags = custom_without_assign!(:post,
|
79
|
+
"/v1/customers/#{uuid}/attributes/tags",
|
80
|
+
tags: tags)[:tags]
|
81
|
+
end
|
82
|
+
|
83
|
+
def remove_tags!(*tags)
|
84
|
+
self.tags = custom_without_assign!(:delete,
|
85
|
+
"/v1/customers/#{uuid}/attributes/tags",
|
86
|
+
tags: tags)[:tags]
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_custom_attributes!(*custom_attrs)
|
90
|
+
self.custom_attributes = custom_without_assign!(:post,
|
91
|
+
"/v1/customers/#{uuid}/attributes/custom",
|
92
|
+
custom: custom_attrs)[:custom]
|
93
|
+
end
|
94
|
+
|
95
|
+
def update_custom_attributes!(custom_attrs = {})
|
96
|
+
self.custom_attributes = custom_without_assign!(:put,
|
97
|
+
"/v1/customers/#{uuid}/attributes/custom",
|
98
|
+
custom: custom_attrs)[:custom]
|
99
|
+
end
|
100
|
+
|
101
|
+
def remove_custom_attributes!(*custom_attrs)
|
102
|
+
self.custom_attributes = custom_without_assign!(:delete,
|
103
|
+
"/v1/customers/#{uuid}/attributes/custom",
|
104
|
+
custom: custom_attrs)[:custom]
|
105
|
+
end
|
106
|
+
|
107
|
+
def merge_into!(other_customer)
|
108
|
+
options = {
|
109
|
+
from: { customer_uuid: uuid },
|
110
|
+
into: { customer_uuid: other_customer.uuid }
|
111
|
+
}
|
112
|
+
custom!(:post, '/v1/customers/merges', options)
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
47
117
|
|
48
|
-
|
49
|
-
|
50
|
-
|
118
|
+
def tags=(tags)
|
119
|
+
@attributes[:tags] = tags
|
120
|
+
end
|
51
121
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
include Concerns::Pageable2
|
122
|
+
def custom_attributes=(custom_attributes = {})
|
123
|
+
@attributes[:custom] = typecast_custom_attributes(custom_attributes)
|
124
|
+
end
|
56
125
|
|
57
|
-
|
126
|
+
def set_attributes(attributes_attributes)
|
127
|
+
@attributes = attributes_attributes
|
128
|
+
@attributes[:custom] = typecast_custom_attributes(attributes_attributes[:custom])
|
129
|
+
end
|
58
130
|
|
59
|
-
|
60
|
-
|
61
|
-
|
131
|
+
def typecast_custom_attributes(custom_attributes)
|
132
|
+
return {} unless custom_attributes
|
133
|
+
custom_attributes.each_with_object({}) do |(key, value), hash|
|
134
|
+
hash[key] = value.instance_of?(String) ? (Time.parse(value) rescue value) : value
|
62
135
|
end
|
63
136
|
end
|
64
137
|
end
|
138
|
+
|
139
|
+
class Customers < APIResource
|
140
|
+
set_resource_name 'Customers'
|
141
|
+
set_resource_path '/v1/customers'
|
142
|
+
|
143
|
+
include Concerns::Entries
|
144
|
+
include API::Actions::Custom
|
145
|
+
include Concerns::Pageable
|
146
|
+
include Concerns::Pageable2
|
147
|
+
|
148
|
+
set_entry_class Customer
|
149
|
+
|
150
|
+
def self.search(email)
|
151
|
+
path = ChartMogul::ResourcePath.new('/v1/customers/search')
|
152
|
+
custom!(:get, path.apply_with_get_params(email: email))
|
153
|
+
end
|
154
|
+
end
|
65
155
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module ChartMogul
|
2
2
|
module Enrichment
|
3
|
-
|
3
|
+
|
4
|
+
# <b>DEPRECATED:</b> Please use <tt>ChartMogul/Customer</tt> instead.
|
5
|
+
class DeprecatedCustomer < APIResource
|
6
|
+
|
4
7
|
set_resource_name 'Customer'
|
5
8
|
set_resource_path '/v1/customers'
|
6
9
|
|
@@ -113,6 +116,12 @@ module ChartMogul
|
|
113
116
|
end
|
114
117
|
end
|
115
118
|
|
119
|
+
def self.const_missing(const_name)
|
120
|
+
super unless const_name == :Customer
|
121
|
+
warn "DEPRECATION WARNING: the class ChartMogul::Enrichment::Customer is deprecated. Use ChartMogul::Customer instead."
|
122
|
+
DeprecatedCustomer
|
123
|
+
end
|
124
|
+
|
116
125
|
class Customers < APIResource
|
117
126
|
set_resource_name 'Customers'
|
118
127
|
set_resource_path '/v1/customers'
|
@@ -121,7 +130,7 @@ module ChartMogul
|
|
121
130
|
include API::Actions::Custom
|
122
131
|
include Concerns::Pageable
|
123
132
|
|
124
|
-
set_entry_class
|
133
|
+
set_entry_class DeprecatedCustomer
|
125
134
|
|
126
135
|
def self.search(email)
|
127
136
|
path = ChartMogul::ResourcePath.new('/v1/customers/search')
|
data/lib/chartmogul/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.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: 2017-
|
11
|
+
date: 2017-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -112,8 +112,21 @@ files:
|
|
112
112
|
- bin/setup
|
113
113
|
- changelog.md
|
114
114
|
- chartmogul-ruby.gemspec
|
115
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml
|
116
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_required_tags.yml
|
115
117
|
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_handles_a_422_response.yml
|
116
118
|
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_interracts_with_the_API.yml
|
119
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/merges_customers.yml
|
120
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_401_if_invalid_credentials.yml
|
121
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_404_if_no_customers_found.yml
|
122
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_422_for_update_with_invalid_data.yml
|
123
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_custom_attributes.yml
|
124
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_tags.yml
|
125
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml
|
126
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml
|
127
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml
|
128
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml
|
129
|
+
- fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer.yml
|
117
130
|
- fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml
|
118
131
|
- fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_nil_if_customer_does_not_exist.yml
|
119
132
|
- fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml
|
@@ -121,19 +134,6 @@ files:
|
|
121
134
|
- fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_404.yml
|
122
135
|
- fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_422.yml
|
123
136
|
- fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/retrieves_existing_data_source_matching_uuid.yml
|
124
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/adds_custom_attributes.yml
|
125
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/adds_required_tags.yml
|
126
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/merges_customers.yml
|
127
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/raises_401_if_invalid_credentials.yml
|
128
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/raises_404_if_no_customers_found.yml
|
129
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/raises_422_for_update_with_invalid_data.yml
|
130
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/removes_custom_attributes.yml
|
131
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/removes_tags.yml
|
132
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml
|
133
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml
|
134
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml
|
135
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/updates_custom_attributes.yml
|
136
|
-
- fixtures/vcr_cassettes/ChartMogul_Enrichment_Customer/API_Interactions/updates_customer.yml
|
137
137
|
- fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
|
138
138
|
- fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/should_have_entries.yml
|
139
139
|
- fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
|