nurego 1.0.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/README.md +271 -178
- data/VERSION +1 -1
- data/lib/nurego/organization.rb +6 -6
- data/lib/nurego/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWUyMWM5Yjc0MzA2NDFjYjhiOThjMDYxMWQ2YmUxMTdhZTJlMzI0NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmIxMmZjODhmMjJiODI4M2M1ZDE3MThhMDc4MDIwZjY1MTkyMTViMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWVjZDNjNjllZjJmMTI2YzZhZmU2NTZmYmM3YWQ3N2YwMTRjMTUyN2IyMDJj
|
10
|
+
ZDg4MzU5MWE4MTU2NjYyMzQ2ZTFjNjMyNTI1MDFhZGE3MjI1MTg4MDQyOWFl
|
11
|
+
MzEzM2RiY2Y1ZGMyZmY3MmZlODYyZTg4ZDMzNmI5NDkxYzE0NWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjYzMDJkZjM3OTgxMTQ3ZDA1ZTM4NzU0NDk5NWNjNTMwNmRmNjg5M2YzMDY2
|
14
|
+
YjA3YjI1ZTY4NWNiNGIyMTY4NWJhYTE0NzU4NzJlZDQ1Y2IzNjM0MWU4ZWZi
|
15
|
+
ODMzY2Q4ODdjMDQ4MDc0MTdiYjM0ZDU0Y2M4NzRhNTM5YWNjNjg=
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,178 +1,271 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
1
|
+
Overview
|
2
|
+
|
3
|
+
|
4
|
+
Nurego-Ruby is simple Ruby bindings library allows easy access to Nurego system, without any hassle of dealing with REST APIs and object mapping. Each object in the system has its own Ruby representation. There are relationships between some of them and they can be traversed using Nurego-Ruby API. The following objects can be used by the customers of Nurego-Ruby:
|
5
|
+
Bill
|
6
|
+
Connector
|
7
|
+
Customer
|
8
|
+
Entitlement
|
9
|
+
Feature
|
10
|
+
Instance
|
11
|
+
Offering
|
12
|
+
Organization
|
13
|
+
Password Reset
|
14
|
+
Payment Method
|
15
|
+
Plan
|
16
|
+
Registration
|
17
|
+
Some of the objects allow simple CRUD (or subset of it), when the others hide more complex operations like password reset.
|
18
|
+
|
19
|
+
Initialization
|
20
|
+
|
21
|
+
require “nurego”
|
22
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
23
|
+
|
24
|
+
Your API key can be obtained from Settings/Organization
|
25
|
+
Authorization
|
26
|
+
|
27
|
+
|
28
|
+
Some of the operations require customer login (TBD)
|
29
|
+
|
30
|
+
Error handling
|
31
|
+
|
32
|
+
|
33
|
+
Several errors can be thrown by the library. The base class for all Nurego errors is Nurego::NuregoError
|
34
|
+
|
35
|
+
Additional error that can be thrown by the library are:
|
36
|
+
|
37
|
+
Nurego::APIConnectionError - failed to connect to the Nurego API endpoing
|
38
|
+
Nurego::APIErrror - bad response from API endpoint
|
39
|
+
Nurego::CardError - invalid token was provided
|
40
|
+
Nurego::UserNotFoundError - user not found
|
41
|
+
Nurego::InvalidRequestError - the request to the API endpoint was bad or had wrong arguments
|
42
|
+
Nurego::AuthenticationError - bad API key or username/password was provided
|
43
|
+
|
44
|
+
Entitlement
|
45
|
+
|
46
|
+
|
47
|
+
To use an entitlement object you need to obtain customer external ID. In case of Stripe it will be Stripe customer ID (guid starting with cus_
|
48
|
+
|
49
|
+
Get entitlement for customer
|
50
|
+
begin
|
51
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
52
|
+
|
53
|
+
Nurego.login(username, password)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
customer = Nurego::Customer.me
|
58
|
+
organization = customer.organizations[0]
|
59
|
+
ents = organization.entitlements(nil, customer_id)
|
60
|
+
rescue Nurego::NuregoError => e
|
61
|
+
puts “Got exception #{e}”
|
62
|
+
end
|
63
|
+
|
64
|
+
[#<Nurego::NuregoObject:0x18b83b8> JSON: {
|
65
|
+
"id": "dba33a54-57dc-4a29-abf7-0a83aa7c1961",
|
66
|
+
"object": "entitlement",
|
67
|
+
"feature_name": "subscribers",
|
68
|
+
"max_allowed_amount": 10
|
69
|
+
}]
|
70
|
+
|
71
|
+
Get entitlements for customer and feature
|
72
|
+
begin
|
73
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
74
|
+
|
75
|
+
Nurego.login(username, password)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
customer = Nurego::Customer.me
|
80
|
+
organization = customer.organizations[0]
|
81
|
+
ents = organization.entitlements(feature_id, customer_id)
|
82
|
+
rescue Nurego::NuregoError => e
|
83
|
+
puts “Got exception #{e}”
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
Submit usage for customer
|
91
|
+
begin
|
92
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
93
|
+
|
94
|
+
Nurego.login(username, password)
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
ent = Nurego::Entitlement.new({id: customer_id})
|
99
|
+
ent.set_usage(feature_id, max_amount - 1)
|
100
|
+
rescue Nurego::NuregoError => e
|
101
|
+
puts “Got exception #{e}”
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
Check allowed usage for customer
|
106
|
+
begin
|
107
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
108
|
+
|
109
|
+
Nurego.login(username, password)
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
customer = Nurego::Customer.me
|
114
|
+
organization = customer.organizations[0]
|
115
|
+
ents = organization.entitlements(feature_id, customer_id)
|
116
|
+
ent = ents[0]
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
allowed = ent.is_allowed(feature_id, 1)
|
121
|
+
puts "#{allowed.inspect}"
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
allowed = ent.is_allowed(feature_id, 2)
|
126
|
+
puts "#{allowed.inspect}"
|
127
|
+
rescue Nurego::NuregoError => e
|
128
|
+
puts “Got exception #{e}”
|
129
|
+
end
|
130
|
+
|
131
|
+
Feature
|
132
|
+
|
133
|
+
begin
|
134
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
135
|
+
offering = Nurego::Offering.current
|
136
|
+
offering.plans.each do |plan|
|
137
|
+
puts plan.inspect
|
138
|
+
plan.features.each do |feature|
|
139
|
+
puts feature.inspect
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
Response will look like this
|
144
|
+
#<Nurego::Feature:0x1285518> JSON: {
|
145
|
+
"id": "id",
|
146
|
+
"object": "feature",
|
147
|
+
"name": "Funds Service",
|
148
|
+
"element_type": "feature",
|
149
|
+
"price": 0.0,
|
150
|
+
"min_unit": 0,
|
151
|
+
"max_unit": 0,
|
152
|
+
"period": "monthly",
|
153
|
+
"billing_period_interval": 1,
|
154
|
+
"unit_type": {"name":"Funds Service","consumable":false,"apply_repetition":0,"guid":"cd96f327-e1e1-4081-8717-a5baaae4984e"}
|
155
|
+
}
|
156
|
+
Offering
|
157
|
+
|
158
|
+
Retrieve the current offering for the 'All' segment through the 'website' distribution channel.
|
159
|
+
begin
|
160
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
161
|
+
offering = Nurego::Offering.current
|
162
|
+
puts offering.inspect
|
163
|
+
end
|
164
|
+
|
165
|
+
To retrieve offerings available for a particular segment and/or distribution channel, add the optional :segment_guid and/or :distribution_channel parameters. To learn more about segments and distribution channels, take a look at the documentation
|
166
|
+
begin
|
167
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
168
|
+
offering = Nurego::Offering.current({:segment_guid => '<SEGMENT>', :distribution_channel => '<CHANNEL>'})
|
169
|
+
puts offering.inspect
|
170
|
+
end
|
171
|
+
Response will look like this
|
172
|
+
#<Nurego::ListObject:0x1412db8> JSON: {
|
173
|
+
"data": [
|
174
|
+
{
|
175
|
+
"id": "ce24d45f-4b33-41d3-a3cb-d46ad411c086",
|
176
|
+
"object": "plan",
|
177
|
+
"name": "Entry Level",
|
178
|
+
"description": null,
|
179
|
+
"plan_status": "active",
|
180
|
+
"credit_card": false,
|
181
|
+
"plan_order": 0,
|
182
|
+
"discounts": [
|
183
|
+
|
184
|
+
],
|
185
|
+
"features": {
|
186
|
+
"data": [
|
187
|
+
{
|
188
|
+
"id": "id",
|
189
|
+
"object": "feature",
|
190
|
+
"name": "Email Support",
|
191
|
+
"element_type": "feature",
|
192
|
+
"price": 0,
|
193
|
+
"min_unit": 0,
|
194
|
+
"max_unit": 0,
|
195
|
+
"period": "monthly",
|
196
|
+
"billing_period_interval": 1,
|
197
|
+
"unit_type": {
|
198
|
+
"name": "Email Support",
|
199
|
+
"consumable": false,
|
200
|
+
"apply_repetition": 0,
|
201
|
+
"guid": "dba33a54-57dc-4a29-abf7-0a83aa7c1961"
|
202
|
+
}
|
203
|
+
},
|
204
|
+
{
|
205
|
+
"id": "id",
|
206
|
+
"object": "feature",
|
207
|
+
"name": "Financial News Service",
|
208
|
+
"element_type": "feature",
|
209
|
+
"price": 0,
|
210
|
+
"min_unit": 0,
|
211
|
+
"max_unit": 0,
|
212
|
+
"period": "monthly",
|
213
|
+
"billing_period_interval": 1,
|
214
|
+
"unit_type": {
|
215
|
+
"name": "Financial News Service",
|
216
|
+
"consumable": false,
|
217
|
+
"apply_repetition": 0,
|
218
|
+
"guid": "7de73a31-db39-4aa7-a8c2-8c1d325ec080"
|
219
|
+
}
|
220
|
+
},
|
221
|
+
{
|
222
|
+
"id": "id",
|
223
|
+
"object": "feature",
|
224
|
+
"name": "Indices Services",
|
225
|
+
"element_type": "feature",
|
226
|
+
"price": 0,
|
227
|
+
"min_unit": 0,
|
228
|
+
"max_unit": 2,
|
229
|
+
"period": "monthly",
|
230
|
+
"billing_period_interval": 1,
|
231
|
+
"unit_type": {
|
232
|
+
"name": "Indices Services",
|
233
|
+
"consumable": false,
|
234
|
+
"apply_repetition": 0,
|
235
|
+
"guid": "65531b5f-a1af-474e-8709-65f49b6c6ad8"
|
236
|
+
}
|
237
|
+
},
|
238
|
+
{
|
239
|
+
"id": "id",
|
240
|
+
"object": "feature",
|
241
|
+
"name": "recurring",
|
242
|
+
"element_type": "recurring",
|
243
|
+
"price": 0,
|
244
|
+
"min_unit": 0,
|
245
|
+
"max_unit": 0,
|
246
|
+
"period": "monthly",
|
247
|
+
"billing_period_interval": 1
|
248
|
+
}
|
249
|
+
],
|
250
|
+
"object": "list",
|
251
|
+
"count": 4,
|
252
|
+
"url": "\/v1\/plans\/ce24d45f-4b33-41d3-a3cb-d46ad411c086\/features"
|
253
|
+
}
|
254
|
+
}
|
255
|
+
],
|
256
|
+
"object": "list",
|
257
|
+
"count": 1,
|
258
|
+
"url": "/v1/offerings/013ddd26-131d-43f9-95e3-790111a91dad/plans"
|
259
|
+
}
|
260
|
+
|
261
|
+
Plan
|
262
|
+
|
263
|
+
The :distribution_channel and :segment_guid params are optional. Use them to call plans for a specific distribution channel and/or segment. To learn more about creating segments and distribution channels, check out the documentation
|
264
|
+
begin
|
265
|
+
Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
|
266
|
+
offering = Nurego::Offering.current({:segment_guid => '<SEGMENT>', :distribution_channel => '<CHANNEL>'})
|
267
|
+
|
268
|
+
offering.plans.each do |plan|
|
269
|
+
puts plan.inspect
|
270
|
+
end
|
271
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.11
|
data/lib/nurego/organization.rb
CHANGED
@@ -15,12 +15,12 @@ module Nurego
|
|
15
15
|
Bill.all({ :organization => id }, @api_key)[:bills]
|
16
16
|
end
|
17
17
|
|
18
|
-
def entitlements(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
def self.entitlements(params = {}, api_key = nil)
|
19
|
+
Entitlement.all({:organization => params[:customer_id], :feature_id => params[:feature_id] }, api_key)
|
20
|
+
end
|
21
|
+
|
22
|
+
def entitlements(feature_id = nil)
|
23
|
+
Entitlement.all({:organization => id, :feature_id => feature_id, :provider_name => 'internal' }, @api_key)
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
data/lib/nurego/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nurego
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilia Gilderman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|