nurego 1.1.11 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWUyMWM5Yjc0MzA2NDFjYjhiOThjMDYxMWQ2YmUxMTdhZTJlMzI0NA==
4
+ MTMyNjE4YTM0ZjY3Y2M4ZjNmZjMyNTZlNmNkY2Q1MGY1MDNjYTg2NA==
5
5
  data.tar.gz: !binary |-
6
- YmIxMmZjODhmMjJiODI4M2M1ZDE3MThhMDc4MDIwZjY1MTkyMTViMA==
6
+ OWZjNTFkOWYwODA0NDFlMWZmZGNkNzYxZDVmYTUwNGFmYWE1MjUxOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWVjZDNjNjllZjJmMTI2YzZhZmU2NTZmYmM3YWQ3N2YwMTRjMTUyN2IyMDJj
10
- ZDg4MzU5MWE4MTU2NjYyMzQ2ZTFjNjMyNTI1MDFhZGE3MjI1MTg4MDQyOWFl
11
- MzEzM2RiY2Y1ZGMyZmY3MmZlODYyZTg4ZDMzNmI5NDkxYzE0NWE=
9
+ NzBkMGExYjEzNTFhMjkxZTNmYmE2NjBkNDMyOTU3NWZmZmViOWQzYzM0OTdm
10
+ MjQyMmFmMWI2YjRiMjQ2NmJjZmYyOTgyZDcxZTg4MDFkZjhmMzJmY2ExYTE0
11
+ NjIwODUzNTVlZmIwMjYxNmIxNDVjNjcwMjhiYzdmOWI4YzFjOTk=
12
12
  data.tar.gz: !binary |-
13
- NjYzMDJkZjM3OTgxMTQ3ZDA1ZTM4NzU0NDk5NWNjNTMwNmRmNjg5M2YzMDY2
14
- YjA3YjI1ZTY4NWNiNGIyMTY4NWJhYTE0NzU4NzJlZDQ1Y2IzNjM0MWU4ZWZi
15
- ODMzY2Q4ODdjMDQ4MDc0MTdiYjM0ZDU0Y2M4NzRhNTM5YWNjNjg=
13
+ ZWM0MTkwMzljNWVmZDc4NWM2YjJjYTllOTAxZGRmYTVlMTU0MWFkNzJhZGM4
14
+ NzgwYTk1NDU2MjhlOTRiN2JiMGUzNTEyNTY1N2FhN2QzNDY3YTM2OTA5OWFk
15
+ NjY4NDVjYzE5Mjg2NzZjZGVkN2IwODNkODhjYzY3ODUxZDk5NGY=
data/README.md CHANGED
@@ -1,33 +1,38 @@
1
- Overview
1
+ #Overview
2
2
 
3
3
 
4
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
5
+
6
+ - Bill
7
+ - Connector
8
+ - Customer
9
+ - Entitlement
10
+ - Feature
11
+ - Instance
12
+ - Offering
13
+ - Organization
14
+ - Password Reset
15
+ - Payment Method
16
+ - Plan
17
+ - Registration
18
+
17
19
  Some of the objects allow simple CRUD (or subset of it), when the others hide more complex operations like password reset.
18
20
 
19
- Initialization
21
+ #Initialization
20
22
 
23
+ ```
21
24
  require “nurego”
22
25
  Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
26
+ ```
23
27
 
24
- Your API key can be obtained from Settings/Organization
25
- Authorization
28
+ Your API key can be obtained from Settings/Integration
29
+
30
+ #Authorization
26
31
 
27
32
 
28
33
  Some of the operations require customer login (TBD)
29
34
 
30
- Error handling
35
+ #Error handling
31
36
 
32
37
 
33
38
  Several errors can be thrown by the library. The base class for all Nurego errors is Nurego::NuregoError
@@ -41,135 +46,105 @@ Nurego::UserNotFoundError - user not found
41
46
  Nurego::InvalidRequestError - the request to the API endpoint was bad or had wrong arguments
42
47
  Nurego::AuthenticationError - bad API key or username/password was provided
43
48
 
44
- Entitlement
45
-
49
+ #Entitlement
46
50
 
47
51
  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
52
 
49
53
  Get entitlement for customer
50
- begin
51
- Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
52
-
53
- Nurego.login(username, password)
54
-
55
54
 
56
-
57
- customer = Nurego::Customer.me
58
- organization = customer.organizations[0]
59
- ents = organization.entitlements(nil, customer_id)
55
+ ```
56
+ begin
57
+ Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
58
+ ents = Nurego::Organization.entitlements({customer_id: 'cus_2shm2PizVL8QOp'})
59
+ puts ents.inspect
60
60
  rescue Nurego::NuregoError => e
61
61
  puts “Got exception #{e}”
62
62
  end
63
+ ```
63
64
 
65
+ ```
64
66
  [#<Nurego::NuregoObject:0x18b83b8> JSON: {
65
67
  "id": "dba33a54-57dc-4a29-abf7-0a83aa7c1961",
66
68
  "object": "entitlement",
67
69
  "feature_name": "subscribers",
68
70
  "max_allowed_amount": 10
69
71
  }]
72
+ ```
70
73
 
71
- Get entitlements for customer and feature
72
- begin
74
+ ```
75
+ begin
73
76
  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)
77
+ ents = Nurego::Organization.entitlements({customer_id: 'cus_2shm2PizVL8QOp', feature_id: 'subscribers'})
78
+ puts ents.inspect
82
79
  rescue Nurego::NuregoError => e
83
80
  puts “Got exception #{e}”
84
-
85
-
86
-
87
81
  end
82
+ ```
88
83
 
84
+ ```
85
+ [#<Nurego::NuregoObject:0x18b83b8> JSON: {
86
+ "id": "dba33a54-57dc-4a29-abf7-0a83aa7c1961",
87
+ "object": "entitlement",
88
+ "feature_name": "subscribers",
89
+ "max_allowed_amount": 10
90
+ }]
91
+ ```
89
92
 
90
93
  Submit usage for customer
91
- begin
92
- Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
93
-
94
- Nurego.login(username, password)
95
-
96
94
 
97
-
98
- ent = Nurego::Entitlement.new({id: customer_id})
95
+ ```
96
+ begin
97
+ Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
98
+ ent = Nurego::Entitlement.new({id: 'cus_2shm2PizVL8QOp'})
99
99
  ent.set_usage(feature_id, max_amount - 1)
100
100
  rescue Nurego::NuregoError => e
101
101
  puts “Got exception #{e}”
102
102
  end
103
-
103
+ ```
104
104
 
105
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
106
 
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}"
107
+ ```
108
+ begin
109
+ Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
110
+ ent = Nurego::Entitlement.new({id: 'cus_2shm2PizVL8QOp'})
111
+
112
+ allowed = ent.is_allowed(feature_id, 1)
113
+ puts allowed.inspect
114
+
115
+ allowed = ent.is_allowed(feature_id, 2)
116
+ puts allowed.inspect
127
117
  rescue Nurego::NuregoError => e
128
118
  puts “Got exception #{e}”
129
119
  end
120
+ ```
130
121
 
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
122
+ #Offering
157
123
 
158
124
  Retrieve the current offering for the 'All' segment through the 'website' distribution channel.
159
- begin
125
+
126
+ ```
127
+ begin
160
128
  Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
161
129
  offering = Nurego::Offering.current
162
130
  puts offering.inspect
163
131
  end
132
+ ```
164
133
 
165
134
  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
135
+
136
+ ```
137
+ begin
167
138
  Nurego.api_key = “l230bc7b-9b85-4c5f-ad9f-4eeeef4d4f44”
168
139
  offering = Nurego::Offering.current({:segment_guid => '<SEGMENT>', :distribution_channel => '<CHANNEL>'})
169
140
  puts offering.inspect
170
141
  end
171
- Response will look like this
172
- #<Nurego::ListObject:0x1412db8> JSON: {
142
+ ```
143
+
144
+ Response will look like this
145
+
146
+ ```
147
+ #<Nurego::ListObject:0x1412db8> JSON: {
173
148
  "data": [
174
149
  {
175
150
  "id": "ce24d45f-4b33-41d3-a3cb-d46ad411c086",
@@ -257,15 +232,15 @@ end
257
232
  "count": 1,
258
233
  "url": "/v1/offerings/013ddd26-131d-43f9-95e3-790111a91dad/plans"
259
234
  }
235
+ ```
260
236
 
261
- Plan
237
+ To retrive the plan object that given customer is subscribed to, the following code should be run
262
238
 
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
239
+ ```
240
+ begin
265
241
  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
242
+ plan = Nurego::Offering.my_plan({customer_id: 'cus_2shm2PizVL8QOp'})
243
+ puts plan.inspect
271
244
  end
245
+ ```
246
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.11
1
+ 1.1.12
@@ -35,6 +35,10 @@ module Nurego
35
35
  raise NuregoError "fetch_access_info #{e.inspect}"
36
36
  end
37
37
 
38
+ def set_header_token(token)
39
+ @header_token = token
40
+ end
41
+
38
42
  private
39
43
  def fetch_access_info(username, password)
40
44
  token = token_issuer.owner_password_grant(username, password)
@@ -1,3 +1,3 @@
1
1
  module Nurego
2
- VERSION = '1.1.11'
2
+ VERSION = IO.read(File.expand_path("../../../VERSION", __FILE__))
3
3
  end
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.1.11
4
+ version: 1.1.12
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-27 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client