client_success 0.1.2

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +466 -0
  5. data/.travis.yml +7 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +111 -0
  8. data/README.md +52 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/client_success.gemspec +44 -0
  13. data/lib/client_success/access_token.rb +25 -0
  14. data/lib/client_success/client.rb +115 -0
  15. data/lib/client_success/client_type.rb +18 -0
  16. data/lib/client_success/connection.rb +99 -0
  17. data/lib/client_success/contact.rb +104 -0
  18. data/lib/client_success/domain_model/access_token.rb +11 -0
  19. data/lib/client_success/domain_model/client.rb +14 -0
  20. data/lib/client_success/domain_model/client_type.rb +14 -0
  21. data/lib/client_success/domain_model/contact.rb +14 -0
  22. data/lib/client_success/domain_model/custom_field_value.rb +9 -0
  23. data/lib/client_success/domain_model/employee.rb +14 -0
  24. data/lib/client_success/domain_model/product.rb +10 -0
  25. data/lib/client_success/domain_model/security_role.rb +9 -0
  26. data/lib/client_success/domain_model/status.rb +9 -0
  27. data/lib/client_success/domain_model/subscription.rb +12 -0
  28. data/lib/client_success/domain_model/success_cycle.rb +9 -0
  29. data/lib/client_success/domain_model/to_do.rb +9 -0
  30. data/lib/client_success/employee.rb +18 -0
  31. data/lib/client_success/product.rb +16 -0
  32. data/lib/client_success/schema/client/create.rb +34 -0
  33. data/lib/client_success/schema/client/update.rb +37 -0
  34. data/lib/client_success/schema/contact/create.rb +28 -0
  35. data/lib/client_success/schema/contact/update.rb +27 -0
  36. data/lib/client_success/schema/subscription/create.rb +20 -0
  37. data/lib/client_success/schema/subscription/update.rb +21 -0
  38. data/lib/client_success/status.rb +23 -0
  39. data/lib/client_success/subscription.rb +51 -0
  40. data/lib/client_success/to_do.rb +23 -0
  41. data/lib/client_success/types.rb +7 -0
  42. data/lib/client_success/version.rb +3 -0
  43. data/lib/client_success.rb +18 -0
  44. metadata +266 -0
@@ -0,0 +1,28 @@
1
+ require_relative "../../types"
2
+
3
+ module ClientSuccess
4
+ module Schema
5
+ module Contact
6
+ # TODO: upgrade dry types to use latest schema functions
7
+ Create = Types::Hash.schema(
8
+ email: Types::Strict::String,
9
+ phone: Types::Strict::String.optional,
10
+ mobile: Types::Strict::String.optional,
11
+ title: Types::Strict::String.optional,
12
+ linkedin_url: Types::Strict::String,
13
+ first_name: Types::Strict::String.optional,
14
+ last_name: Types::Strict::String.optional,
15
+ executive_sponsor: Types::Strict::Bool,
16
+ advocate: Types::Strict::Bool,
17
+ champion: Types::Strict::Bool,
18
+ starred: Types::Strict::Bool,
19
+ street: Types::Strict::String,
20
+ city: Types::Strict::String,
21
+ contact_state: Types::Strict::String,
22
+ zip: Types::Coercible::String,
23
+ country: Types::Strict::String,
24
+ timezone: Types::Strict::String
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "../../types"
2
+
3
+ module ClientSuccess
4
+ module Schema
5
+ module Contact
6
+ # TODO: upgrade dry types to use latest schema functions
7
+ Update = Types::Hash.schema(
8
+ email: Types::Strict::String,
9
+ phone: Types::Strict::String.optional,
10
+ mobile: Types::Strict::String.optional,
11
+ title: Types::Strict::String.optional,
12
+ linkedin_url: Types::Strict::String.optional,
13
+ first_name: Types::Strict::String.optional,
14
+ last_name: Types::Strict::String.optional,
15
+ executive_sponsor: Types::Strict::Bool,
16
+ advocate: Types::Strict::Bool,
17
+ champion: Types::Strict::Bool,
18
+ starred: Types::Strict::Bool,
19
+ street: Types::Strict::String.optional,
20
+ city: Types::Strict::String.optional,
21
+ contact_state: Types::Strict::String.optional,
22
+ zip: Types::Coercible::String.optional,
23
+ country: Types::Strict::String.optional,
24
+ timezone: Types::Strict::String.optional)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,20 @@
1
+ require_relative "../../types"
2
+
3
+ module ClientSuccess
4
+ module Schema
5
+ module Subscription
6
+ Create = Types::Hash.schema(
7
+ product_id: Types::Coercible::Int,
8
+ is_recurring: Types::Strict::Bool,
9
+ amount: Types::Coercible::Int,
10
+ quantity: Types::Coercible::Int,
11
+ start_date: Types::Strict::String,
12
+ end_date: Types::Strict::String,
13
+ is_potential: Types::Strict::Bool,
14
+ auto_renew: Types::Strict::Bool,
15
+ note: Types::Strict::Hash,
16
+ client_id: Types::Coercible::Int
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require_relative "../../types"
2
+
3
+ module ClientSuccess
4
+ module Schema
5
+ module Subscription
6
+ Update = Types::Hash.schema(
7
+ product_id: Types::Coercible::Int,
8
+ is_recurring: Types::Strict::Bool,
9
+ amount: Types::Coercible::Int,
10
+ quantity: Types::Coercible::Int,
11
+ start_date: Types::Strict::String,
12
+ end_date: Types::Strict::String,
13
+ is_potential: Types::Strict::Bool,
14
+ auto_renew: Types::Strict::Bool,
15
+ note: Types::Strict::Hash,
16
+ client_id: Types::Coercible::Int,
17
+ id: Types::Coercible::Int
18
+ )
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "connection"
2
+ require_relative "domain_model/status"
3
+
4
+ module ClientSuccess
5
+ module Status
6
+ ACTIVE = 1
7
+ INACTIVE = 2
8
+ TRIAL = 3
9
+ TERMINATED = 4
10
+
11
+ extend self
12
+
13
+ def list_all(connection:)
14
+ response = connection.get(
15
+ "/v1/client-statuses")
16
+
17
+ response.body.map do |payload|
18
+ DomainModel::Status.new(
19
+ payload.deep_transform_keys(&:underscore))
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ require_relative "domain_model/subscription"
2
+ require_relative "schema/subscription/create"
3
+ require_relative "schema/subscription/update"
4
+
5
+ module ClientSuccess
6
+ module Subscription
7
+ extend self
8
+
9
+ class Error < StandardError; end
10
+ class InvalidAttributes < Error; end
11
+
12
+ def create(attributes:, connection:)
13
+ body = Schema::Subscription::Create[attributes]
14
+ .deep_transform_keys { |k| k.to_s.camelize(:lower) }
15
+ .to_json
16
+
17
+ response = connection.post(
18
+ "/v1/subscriptions", body)
19
+
20
+
21
+ if response.body.blank?
22
+ raise InvalidAttributes, "subscription has invalid attributes"
23
+ else
24
+ payload = response.body
25
+ DomainModel::Subscription.new(
26
+ payload.deep_transform_keys(&:underscore))
27
+ end
28
+ end
29
+
30
+ def update(attributes:, connection:)
31
+ body = Schema::Subscription::Update[attributes]
32
+ .deep_transform_keys { |k| k.to_s.camelize(:lower) }
33
+ .to_json
34
+
35
+ response = connection.put(
36
+ "/v1/subscriptions/#{attributes[:id]}", body)
37
+
38
+ response.body
39
+ end
40
+
41
+ def last(client_id:, connection:)
42
+ response = connection.get(
43
+ "/v1/subscriptions?clientId=#{client_id}")
44
+
45
+ payload = response.body.last.to_h
46
+
47
+ DomainModel::Subscription.new(
48
+ payload.deep_transform_keys(&:underscore))
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+ require_relative "connection"
2
+ require_relative "domain_model/to_do"
3
+
4
+ module ClientSuccess
5
+ module ToDo
6
+ extend self
7
+
8
+ def list_all(client_id:, connection:)
9
+ response = connection.get(
10
+ "/v1/clients/#{client_id}/to-dos")
11
+
12
+ response.body.map do |payload|
13
+ DomainModel::ToDo.new(
14
+ payload.deep_transform_keys(&:underscore))
15
+ end
16
+ end
17
+
18
+ def create(client_id:, attributes:,
19
+ connection:)
20
+ raise NotImplementedError
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ require "dry-types"
2
+
3
+ module ClientSuccess
4
+ module Types
5
+ include Dry::Types.module
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module ClientSuccess
2
+ VERSION = "0.1.2".freeze
3
+ end
@@ -0,0 +1,18 @@
1
+ require "active_support/core_ext/string/inflections"
2
+ require "active_support/core_ext/hash/keys"
3
+ require "active_support/core_ext/object/to_query"
4
+ require "active_support/core_ext/object/blank"
5
+
6
+ require "hashie"
7
+
8
+ require "client_success/access_token"
9
+ require "client_success/client"
10
+ require "client_success/client_type"
11
+ require "client_success/connection"
12
+ require "client_success/contact"
13
+ require "client_success/employee"
14
+ require "client_success/product"
15
+ require "client_success/status"
16
+ require "client_success/subscription"
17
+ require "client_success/to_do"
18
+ require "client_success/types"
metadata ADDED
@@ -0,0 +1,266 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: client_success
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Practice Ignition
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 12.3.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 12.3.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.77.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.77.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: faraday_middleware
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: typhoeus
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: dry-types
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.11.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.11.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: hashie
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: activesupport
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '5.2'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.2'
195
+ description:
196
+ email:
197
+ - dev@practiceignition.com
198
+ executables: []
199
+ extensions: []
200
+ extra_rdoc_files: []
201
+ files:
202
+ - ".gitignore"
203
+ - ".rspec"
204
+ - ".rubocop.yml"
205
+ - ".travis.yml"
206
+ - Gemfile
207
+ - Gemfile.lock
208
+ - README.md
209
+ - Rakefile
210
+ - bin/console
211
+ - bin/setup
212
+ - client_success.gemspec
213
+ - lib/client_success.rb
214
+ - lib/client_success/access_token.rb
215
+ - lib/client_success/client.rb
216
+ - lib/client_success/client_type.rb
217
+ - lib/client_success/connection.rb
218
+ - lib/client_success/contact.rb
219
+ - lib/client_success/domain_model/access_token.rb
220
+ - lib/client_success/domain_model/client.rb
221
+ - lib/client_success/domain_model/client_type.rb
222
+ - lib/client_success/domain_model/contact.rb
223
+ - lib/client_success/domain_model/custom_field_value.rb
224
+ - lib/client_success/domain_model/employee.rb
225
+ - lib/client_success/domain_model/product.rb
226
+ - lib/client_success/domain_model/security_role.rb
227
+ - lib/client_success/domain_model/status.rb
228
+ - lib/client_success/domain_model/subscription.rb
229
+ - lib/client_success/domain_model/success_cycle.rb
230
+ - lib/client_success/domain_model/to_do.rb
231
+ - lib/client_success/employee.rb
232
+ - lib/client_success/product.rb
233
+ - lib/client_success/schema/client/create.rb
234
+ - lib/client_success/schema/client/update.rb
235
+ - lib/client_success/schema/contact/create.rb
236
+ - lib/client_success/schema/contact/update.rb
237
+ - lib/client_success/schema/subscription/create.rb
238
+ - lib/client_success/schema/subscription/update.rb
239
+ - lib/client_success/status.rb
240
+ - lib/client_success/subscription.rb
241
+ - lib/client_success/to_do.rb
242
+ - lib/client_success/types.rb
243
+ - lib/client_success/version.rb
244
+ homepage: https://github.com/ignitionapp/
245
+ licenses: []
246
+ metadata: {}
247
+ post_install_message:
248
+ rdoc_options: []
249
+ require_paths:
250
+ - lib
251
+ required_ruby_version: !ruby/object:Gem::Requirement
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ version: '0'
256
+ required_rubygems_version: !ruby/object:Gem::Requirement
257
+ requirements:
258
+ - - ">="
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ requirements: []
262
+ rubygems_version: 3.0.3
263
+ signing_key:
264
+ specification_version: 4
265
+ summary: An unofficial Ruby wrapper for Client Success's REST API
266
+ test_files: []