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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTNkZjlkZmJiNDBlMWI1NTU2OTVhYjk3OWMzMDg3NWYzMGYyYmJjYQ==
4
+ NWUyMWM5Yjc0MzA2NDFjYjhiOThjMDYxMWQ2YmUxMTdhZTJlMzI0NA==
5
5
  data.tar.gz: !binary |-
6
- ZDU2MzQ2N2MyYmU0YWI4YmI4OTM1ZDc0ZDk5NGExNTc5MzgxNzNjNA==
6
+ YmIxMmZjODhmMjJiODI4M2M1ZDE3MThhMDc4MDIwZjY1MTkyMTViMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTg5NjdlNzMyYjBlYjkxYmY4NGQ5ZmFiMmU1MTFhMjMwNDBiMTgxZWMwODlk
10
- NWZiYzg0MTQxNDhkZTYxNWM2OTdmODc0ZmU5MGIyMDViNzc5Y2Q3NDI4N2Zj
11
- YWRjNDBlNmNmNDNmMGVlMDk4M2MzNzBlZDJjZDJlMTc5Zjk4NzY=
9
+ YWVjZDNjNjllZjJmMTI2YzZhZmU2NTZmYmM3YWQ3N2YwMTRjMTUyN2IyMDJj
10
+ ZDg4MzU5MWE4MTU2NjYyMzQ2ZTFjNjMyNTI1MDFhZGE3MjI1MTg4MDQyOWFl
11
+ MzEzM2RiY2Y1ZGMyZmY3MmZlODYyZTg4ZDMzNmI5NDkxYzE0NWE=
12
12
  data.tar.gz: !binary |-
13
- NzMwMDQxMWYxMzhiOGZmYjA1NDRiYWY3NTFiNGZkNmY3ZDdiMDFjZTBmNWE1
14
- Mzk3NDI2OTVkYjI2YmNjNGM4NjlhMDQxNjhmNTVkZTA0M2QxYTExN2FlZTVl
15
- M2Q2NDk3Y2FhMGYyOWY1N2QwZjQ1OTEwY2M2ZGYxNjZmNzRmNjg=
13
+ NjYzMDJkZjM3OTgxMTQ3ZDA1ZTM4NzU0NDk5NWNjNTMwNmRmNjg5M2YzMDY2
14
+ YjA3YjI1ZTY4NWNiNGIyMTY4NWJhYTE0NzU4NzJlZDQ1Y2IzNjM0MWU4ZWZi
15
+ ODMzY2Q4ODdjMDQ4MDc0MTdiYjM0ZDU0Y2M4NzRhNTM5YWNjNjg=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nurego (1.0.9)
4
+ nurego (1.0.10)
5
5
  cf-uaa-lib (= 1.3.10)
6
6
  mime-types (~> 1.25)
7
7
  multi_json (>= 1.0.4, < 2)
data/README.md CHANGED
@@ -1,178 +1,271 @@
1
- <h3>Overview</h3><br>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:<br><ul><li>Bill</li><li>Connector</li><li>Customer</li><li>Entitlement</li><li>Feature</li><li>Instance</li><li>Offering</li><li>Organization</li><li>Password Reset</li><li>Payment Method</li><li>Plan</li><li>Registration</li></ul>Some of the objects allow simple CRUD (or subset of it), when the others hide more complex operations like password reset. <br><br><h3>Initialization</h3>
2
- <pre><span style="color:#400000; ">require</span> “nurego”
3
- Nurego<span style="color:#308080; ">.</span>api_key <span style="color:#308080; ">=</span> “l230bc7b<span style="color:#308080; ">-</span>9b85<span style="color:#308080; ">-</span>4c5f<span style="color:#308080; ">-</span>ad9f<span style="color:#308080; ">-</span>4eeeef4d4f44”
4
- </pre><br>Your API key can be obtained from Settings/Organization<br><h3>Authorization</h3><br>Some of the operations require customer login (TBD)<br><br><h3>Error handling</h3><br>Several errors can be thrown by the library. The base class for all Nurego errors is Nurego::NuregoError<br><br>Additional error that can be thrown by the library are:<br><br>Nurego::APIConnectionError - failed to connect to the Nurego API endpoing<br>Nurego::APIErrror - bad response from API endpoint<br>Nurego::CardError - invalid token was provided<br>Nurego::UserNotFoundError - user not found<br>Nurego::InvalidRequestError - the request to the API endpoint was bad or had wrong arguments<br>Nurego::AuthenticationError - bad API key or username/password was provided<br><h3><br>Entitlement</h3><br> 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_<br><br>Get entitlement for customer<br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(0, 0, 0); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 19.600000381469727px; white-space: normal;"></span><span style="font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; color: rgb(32, 0, 128);">begin</span>
5
- Nureg<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
6
-
7
- Nurego<span style="color: rgb(48, 128, 128);">.</span>login<span style="color: rgb(48, 128, 128);">(</span>username, password<span style="color: rgb(48, 128, 128);">)</span>
8
-
9
- customer <span style="color: rgb(48, 128, 128);">=</span> Nurego::Customer<span style="color: rgb(48, 128, 128);">.</span>me
10
- organization <span style="color: rgb(48, 128, 128);">=</span> customer<span style="color: rgb(48, 128, 128);">.</span>organizations<span style="color: rgb(48, 128, 128);">[</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(48, 128, 128);">]</span>
11
- ents <span style="color: rgb(48, 128, 128);">=</span> organization<span style="color: rgb(48, 128, 128);">.</span>entitlements<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(32, 0, 128); font-weight: bold;">nil</span>, customer_id<span style="color: rgb(48, 128, 128);">)</span>
12
- <span style="color: rgb(32, 0, 128); font-weight: bold;">rescue</span> Nurego::NuregoError <span style="color: rgb(48, 128, 128);">=</span>&gt; e
13
- <span style="color: rgb(64, 0, 0);">puts</span> “Got exception <span style="color: rgb(89, 89, 121);">#{e}”</span>
14
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(16, 96, 182);"></span><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; color: rgb(48, 128, 128);">[</span><span style="font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; color: rgb(89, 89, 121);">#&lt;Nurego::NuregoObject:0x18b83b8&gt; JSON: {</span><span style="color: rgb(16, 96, 182);">
15
- "id"</span>: <span style="color: rgb(16, 96, 182);">"dba33a54-57dc-4a29-abf7-0a83aa7c1961"</span>,
16
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"entitlement"</span>,
17
- <span style="color: rgb(16, 96, 182);">"feature_name"</span>: <span style="color: rgb(16, 96, 182);">"subscribers"</span>,
18
- <span style="color: rgb(16, 96, 182);">"max_allowed_amount"</span>: <span style="color: rgb(0, 140, 0);">10</span>
19
- }<span style="color: rgb(48, 128, 128);">]</span></pre><br>Get entitlements for customer and feature<br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
20
- Nureg<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
21
-
22
- Nurego<span style="color: rgb(48, 128, 128);">.</span>login<span style="color: rgb(48, 128, 128);">(</span>username, password<span style="color: rgb(48, 128, 128);">)</span>
23
-
24
- customer <span style="color: rgb(48, 128, 128);">=</span> Nurego::Customer<span style="color: rgb(48, 128, 128);">.</span>me
25
- organization <span style="color: rgb(48, 128, 128);">=</span> customer<span style="color: rgb(48, 128, 128);">.</span>organizations<span style="color: rgb(48, 128, 128);">[</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(48, 128, 128);">]</span>
26
- ents <span style="color: rgb(48, 128, 128);">=</span> organization<span style="color: rgb(48, 128, 128);">.</span>entitlements<span style="color: rgb(48, 128, 128);">(</span>feature_id, customer_id<span style="color: rgb(48, 128, 128);">)</span>
27
- <span style="color: rgb(32, 0, 128); font-weight: bold;">rescue</span> Nurego::NuregoError <span style="color: rgb(48, 128, 128);">=</span>&gt; e
28
- <span style="color: rgb(64, 0, 0);">puts</span> “Got exception <span style="color: rgb(89, 89, 121);">#{e}”</span>
29
-
30
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><br>Submit usage for customer<br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
31
- Nureg<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
32
-
33
- Nurego<span style="color: rgb(48, 128, 128);">.</span>login<span style="color: rgb(48, 128, 128);">(</span>username, password<span style="color: rgb(48, 128, 128);">)</span>
34
-
35
- ent <span style="color: rgb(48, 128, 128);">=</span> Nurego::Entitlement<span style="color: rgb(48, 128, 128);">.</span><span style="color: rgb(32, 0, 128); font-weight: bold;">new</span><span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(64, 96, 128);">{</span>id: customer_id<span style="color: rgb(64, 96, 128);">}</span><span style="color: rgb(48, 128, 128);">)</span>
36
- ent<span style="color: rgb(48, 128, 128);">.</span>set_usage<span style="color: rgb(48, 128, 128);">(</span>feature_id, max_amount <span style="color: rgb(48, 128, 128);">-</span> <span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">)</span>
37
- <span style="color: rgb(32, 0, 128); font-weight: bold;">rescue</span> Nurego::NuregoError <span style="color: rgb(48, 128, 128);">=</span>&gt; e
38
- <span style="color: rgb(64, 0, 0);">puts</span> “Got exception <span style="color: rgb(89, 89, 121);">#{e}”</span>
39
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><br>Check allowed usage for customer<br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(0, 0, 0); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 19.600000381469727px; white-space: normal;"></span><span style="font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; color: rgb(32, 0, 128);">begin</span>
40
- Nureg<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
41
-
42
- Nurego<span style="color: rgb(48, 128, 128);">.</span>login<span style="color: rgb(48, 128, 128);">(</span>username, password<span style="color: rgb(48, 128, 128);">)</span>
43
-
44
- customer <span style="color: rgb(48, 128, 128);">=</span> Nurego::Customer<span style="color: rgb(48, 128, 128);">.</span>me
45
- organization <span style="color: rgb(48, 128, 128);">=</span> customer<span style="color: rgb(48, 128, 128);">.</span>organizations<span style="color: rgb(48, 128, 128);">[</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(48, 128, 128);">]</span>
46
- ents <span style="color: rgb(48, 128, 128);">=</span> organization<span style="color: rgb(48, 128, 128);">.</span>entitlements<span style="color: rgb(48, 128, 128);">(</span>feature_id, customer_id<span style="color: rgb(48, 128, 128);">)</span>
47
- ent <span style="color: rgb(48, 128, 128);">=</span> ents<span style="color: rgb(48, 128, 128);">[</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(48, 128, 128);">]</span>
48
-
49
-
50
- allowed <span style="color: rgb(48, 128, 128);">=</span> ent<span style="color: rgb(48, 128, 128);">.</span>is_allowed<span style="color: rgb(48, 128, 128);">(</span>feature_id, <span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">)</span>
51
- <span style="color: rgb(64, 0, 0);">puts</span> <span style="color: rgb(16, 96, 182);">"#{allowed.inspect}"</span>
52
-
53
- allowed <span style="color: rgb(48, 128, 128);">=</span> ent<span style="color: rgb(48, 128, 128);">.</span>is_allowed<span style="color: rgb(48, 128, 128);">(</span>feature_id, <span style="color: rgb(0, 140, 0);">2</span><span style="color: rgb(48, 128, 128);">)</span>
54
- <span style="color: rgb(64, 0, 0);">puts</span> <span style="color: rgb(16, 96, 182);">"#{allowed.inspect}"</span>
55
- <span style="color: rgb(32, 0, 128); font-weight: bold;">rescue</span> Nurego::NuregoError <span style="color: rgb(48, 128, 128);">=</span>&gt; e
56
- <span style="color: rgb(64, 0, 0);">puts</span> “Got exception <span style="color: rgb(89, 89, 121);">#{e}”</span>
57
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><h3>Feature</h3><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
58
- Nurego<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
59
- offering <span style="color: rgb(48, 128, 128);">=</span> Nurego::Offering<span style="color: rgb(48, 128, 128);">.</span>current
60
- offering<span style="color: rgb(48, 128, 128);">.</span>plans<span style="color: rgb(48, 128, 128);">.</span><span style="color: rgb(32, 0, 128); font-weight: bold;">each</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">do</span> |plan|
61
- <span style="color: rgb(64, 0, 0);">puts</span> plan<span style="color: rgb(48, 128, 128);">.</span>inspect
62
- plan<span style="color: rgb(48, 128, 128);">.</span>features<span style="color: rgb(48, 128, 128);">.</span><span style="color: rgb(32, 0, 128); font-weight: bold;">each</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">do</span> |feature|
63
- <span style="color: rgb(64, 0, 0);">puts</span> feature<span style="color: rgb(48, 128, 128);">.</span>inspect
64
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span>
65
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><br>Response will look like this<br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(89, 89, 121); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">#&lt;Nurego::Feature:0x1285518&gt; JSON: {</span>
66
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"id"</span>,
67
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
68
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Funds Service"</span>,
69
- <span style="color: rgb(16, 96, 182);">"element_type"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
70
- <span style="color: rgb(16, 96, 182);">"price"</span>: <span style="color: rgb(0, 128, 0);">0.0</span>,
71
- <span style="color: rgb(16, 96, 182);">"min_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
72
- <span style="color: rgb(16, 96, 182);">"max_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
73
- <span style="color: rgb(16, 96, 182);">"period"</span>: <span style="color: rgb(16, 96, 182);">"monthly"</span>,
74
- <span style="color: rgb(16, 96, 182);">"billing_period_interval"</span>: <span style="color: rgb(0, 140, 0);">1</span>,
75
- <span style="color: rgb(16, 96, 182);">"unit_type"</span>: <span style="color: rgb(64, 96, 128);">{</span><span style="color: rgb(16, 96, 182);">"name"</span>:<span style="color: rgb(16, 96, 182);">"Funds Service"</span>,<span style="color: rgb(16, 96, 182);">"consumable"</span>:<span style="color: rgb(32, 0, 128); font-weight: bold;">false</span>,<span style="color: rgb(16, 96, 182);">"apply_repetition"</span>:<span style="color: rgb(0, 140, 0);">0</span>,<span style="color: rgb(16, 96, 182);">"guid"</span>:<span style="color: rgb(16, 96, 182);">"cd96f327-e1e1-4081-8717-a5baaae4984e"</span><span style="color: rgb(64, 96, 128);">}</span>
76
- }</pre><h3>Offering</h3>Retrieve the current offering for the 'All' segment through the 'website' distribution channel.<pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
77
- Nurego<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
78
- offering <span style="color: rgb(48, 128, 128);">=</span> Nurego::Offering<span style="color: rgb(48, 128, 128);">.</span>current
79
- <span style="color: rgb(64, 0, 0);"> puts</span> offering<span style="color: rgb(48, 128, 128);">.</span>inspect
80
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><br>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](http://nurego.com/documentation) <pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
81
- Nurego<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
82
- offering <span style="color: rgb(48, 128, 128);">=</span> Nurego::Offering<span style="color: rgb(48, 128, 128);">.</span>current({:segment_guid => '```<SEGMENT>```', :distribution_channel => '```<CHANNEL>```'})
83
- <span style="color: rgb(64, 0, 0);"> puts</span> offering<span style="color: rgb(48, 128, 128);">.</span>inspect
84
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><span style="font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 19.600000381469727px;">Response will look like this</span><br><pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(16, 96, 182);"></span><span style="color: rgb(89, 89, 121); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">#&lt;Nurego::ListObject:0x1412db8&gt; JSON: {</span><span style="color: rgb(16, 96, 182);">
85
- "data"</span>: <span style="color: rgb(48, 128, 128);">[</span>
86
- <span style="color: rgb(64, 96, 128);">{</span>
87
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"ce24d45f-4b33-41d3-a3cb-d46ad411c086"</span>,
88
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"plan"</span>,
89
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Entry Level"</span>,
90
- <span style="color: rgb(16, 96, 182);">"description"</span>: null,
91
- <span style="color: rgb(16, 96, 182);">"plan_status"</span>: <span style="color: rgb(16, 96, 182);">"active"</span>,
92
- <span style="color: rgb(16, 96, 182);">"credit_card"</span>: <span style="color: rgb(32, 0, 128); font-weight: bold;">false</span>,
93
- <span style="color: rgb(16, 96, 182);">"plan_order"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
94
- <span style="color: rgb(16, 96, 182);">"discounts"</span>: <span style="color: rgb(48, 128, 128);">[</span>
95
-
96
- <span style="color: rgb(48, 128, 128);">]</span>,
97
- <span style="color: rgb(16, 96, 182);">"features"</span>: <span style="color: rgb(64, 96, 128);">{</span>
98
- <span style="color: rgb(16, 96, 182);">"data"</span>: <span style="color: rgb(48, 128, 128);">[</span>
99
- <span style="color: rgb(64, 96, 128);">{</span>
100
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"id"</span>,
101
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
102
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Email Support"</span>,
103
- <span style="color: rgb(16, 96, 182);">"element_type"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
104
- <span style="color: rgb(16, 96, 182);">"price"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
105
- <span style="color: rgb(16, 96, 182);">"min_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
106
- <span style="color: rgb(16, 96, 182);">"max_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
107
- <span style="color: rgb(16, 96, 182);">"period"</span>: <span style="color: rgb(16, 96, 182);">"monthly"</span>,
108
- <span style="color: rgb(16, 96, 182);">"billing_period_interval"</span>: <span style="color: rgb(0, 140, 0);">1</span>,
109
- <span style="color: rgb(16, 96, 182);">"unit_type"</span>: <span style="color: rgb(64, 96, 128);">{</span>
110
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Email Support"</span>,
111
- <span style="color: rgb(16, 96, 182);">"consumable"</span>: <span style="color: rgb(32, 0, 128); font-weight: bold;">false</span>,
112
- <span style="color: rgb(16, 96, 182);">"apply_repetition"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
113
- <span style="color: rgb(16, 96, 182);">"guid"</span>: <span style="color: rgb(16, 96, 182);">"dba33a54-57dc-4a29-abf7-0a83aa7c1961"</span>
114
- <span style="color: rgb(64, 96, 128);">}</span>
115
- <span style="color: rgb(64, 96, 128);">}</span>,
116
- <span style="color: rgb(64, 96, 128);">{</span>
117
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"id"</span>,
118
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
119
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Financial News Service"</span>,
120
- <span style="color: rgb(16, 96, 182);">"element_type"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
121
- <span style="color: rgb(16, 96, 182);">"price"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
122
- <span style="color: rgb(16, 96, 182);">"min_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
123
- <span style="color: rgb(16, 96, 182);">"max_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
124
- <span style="color: rgb(16, 96, 182);">"period"</span>: <span style="color: rgb(16, 96, 182);">"monthly"</span>,
125
- <span style="color: rgb(16, 96, 182);">"billing_period_interval"</span>: <span style="color: rgb(0, 140, 0);">1</span>,
126
- <span style="color: rgb(16, 96, 182);">"unit_type"</span>: <span style="color: rgb(64, 96, 128);">{</span>
127
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Financial News Service"</span>,
128
- <span style="color: rgb(16, 96, 182);">"consumable"</span>: <span style="color: rgb(32, 0, 128); font-weight: bold;">false</span>,
129
- <span style="color: rgb(16, 96, 182);">"apply_repetition"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
130
- <span style="color: rgb(16, 96, 182);">"guid"</span>: <span style="color: rgb(16, 96, 182);">"7de73a31-db39-4aa7-a8c2-8c1d325ec080"</span>
131
- <span style="color: rgb(64, 96, 128);">}</span>
132
- <span style="color: rgb(64, 96, 128);">}</span>,
133
- <span style="color: rgb(64, 96, 128);">{</span>
134
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"id"</span>,
135
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
136
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Indices Services"</span>,
137
- <span style="color: rgb(16, 96, 182);">"element_type"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
138
- <span style="color: rgb(16, 96, 182);">"price"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
139
- <span style="color: rgb(16, 96, 182);">"min_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
140
- <span style="color: rgb(16, 96, 182);">"max_unit"</span>: <span style="color: rgb(0, 140, 0);">2</span>,
141
- <span style="color: rgb(16, 96, 182);">"period"</span>: <span style="color: rgb(16, 96, 182);">"monthly"</span>,
142
- <span style="color: rgb(16, 96, 182);">"billing_period_interval"</span>: <span style="color: rgb(0, 140, 0);">1</span>,
143
- <span style="color: rgb(16, 96, 182);">"unit_type"</span>: <span style="color: rgb(64, 96, 128);">{</span>
144
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"Indices Services"</span>,
145
- <span style="color: rgb(16, 96, 182);">"consumable"</span>: <span style="color: rgb(32, 0, 128); font-weight: bold;">false</span>,
146
- <span style="color: rgb(16, 96, 182);">"apply_repetition"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
147
- <span style="color: rgb(16, 96, 182);">"guid"</span>: <span style="color: rgb(16, 96, 182);">"65531b5f-a1af-474e-8709-65f49b6c6ad8"</span>
148
- <span style="color: rgb(64, 96, 128);">}</span>
149
- <span style="color: rgb(64, 96, 128);">}</span>,
150
- <span style="color: rgb(64, 96, 128);">{</span>
151
- <span style="color: rgb(16, 96, 182);">"id"</span>: <span style="color: rgb(16, 96, 182);">"id"</span>,
152
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"feature"</span>,
153
- <span style="color: rgb(16, 96, 182);">"name"</span>: <span style="color: rgb(16, 96, 182);">"recurring"</span>,
154
- <span style="color: rgb(16, 96, 182);">"element_type"</span>: <span style="color: rgb(16, 96, 182);">"recurring"</span>,
155
- <span style="color: rgb(16, 96, 182);">"price"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
156
- <span style="color: rgb(16, 96, 182);">"min_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
157
- <span style="color: rgb(16, 96, 182);">"max_unit"</span>: <span style="color: rgb(0, 140, 0);">0</span>,
158
- <span style="color: rgb(16, 96, 182);">"period"</span>: <span style="color: rgb(16, 96, 182);">"monthly"</span>,
159
- <span style="color: rgb(16, 96, 182);">"billing_period_interval"</span>: <span style="color: rgb(0, 140, 0);">1</span>
160
- <span style="color: rgb(64, 96, 128);">}</span>
161
- <span style="color: rgb(48, 128, 128);">]</span>,
162
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"list"</span>,
163
- <span style="color: rgb(16, 96, 182);">"count"</span>: <span style="color: rgb(0, 140, 0);">4</span>,
164
- <span style="color: rgb(16, 96, 182);">"url"</span>: <span style="color: rgb(16, 96, 182);">"\/v1\/plans\/ce24d45f-4b33-41d3-a3cb-d46ad411c086\/features"</span>
165
- <span style="color: rgb(64, 96, 128);">}</span>
166
- <span style="color: rgb(64, 96, 128);">}</span>
167
- <span style="color: rgb(48, 128, 128);">]</span>,
168
- <span style="color: rgb(16, 96, 182);">"object"</span>: <span style="color: rgb(16, 96, 182);">"list"</span>,
169
- <span style="color: rgb(16, 96, 182);">"count"</span>: <span style="color: rgb(0, 140, 0);">1</span>,
170
- <span style="color: rgb(16, 96, 182);">"url"</span>: <span style="color: rgb(16, 96, 182);">"/v1/offerings/013ddd26-131d-43f9-95e3-790111a91dad/plans"</span>
171
- }</pre><h3>Plan</h3>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](http://nurego.com/documentation)<pre style="color: rgb(0, 0, 32); font-size: medium; font-style: normal; font-variant: normal; line-height: normal;"><span style="color: rgb(32, 0, 128); font-family: sans-serif; font-size: 14px; font-style: normal; font-variant: normal; line-height: 14px;">begin</span>
172
- Nurego<span style="color: rgb(48, 128, 128);">.</span>api_key <span style="color: rgb(48, 128, 128);">=</span> “l230bc7b<span style="color: rgb(48, 128, 128);">-</span>9b85<span style="color: rgb(48, 128, 128);">-</span>4c5f<span style="color: rgb(48, 128, 128);">-</span>ad9f<span style="color: rgb(48, 128, 128);">-</span>4eeeef4d4f44”
173
- offering <span style="color: rgb(48, 128, 128);">=</span> Nurego::Offering<span style="color: rgb(48, 128, 128);">.</span>current({:segment_guid => '```<SEGMENT>```', :distribution_channel => '```<CHANNEL>```'})
174
-
175
- offering<span style="color: rgb(48, 128, 128);">.</span>plans<span style="color: rgb(48, 128, 128);">.</span><span style="color: rgb(32, 0, 128); font-weight: bold;">each</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">do</span> |plan|
176
- <span style="color: rgb(64, 0, 0);">puts</span> plan<span style="color: rgb(48, 128, 128);">.</span>inspect
177
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span>
178
- <span style="color: rgb(32, 0, 128); font-weight: bold;">end</span></pre><div></div>
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.0.10
1
+ 1.1.11
@@ -15,12 +15,12 @@ module Nurego
15
15
  Bill.all({ :organization => id }, @api_key)[:bills]
16
16
  end
17
17
 
18
- def entitlements(feature_id = nil, external_id = nil)
19
- if external_id
20
- Entitlement.all({:organization => external_id, :feature_id => feature_id }, @api_key)
21
- else
22
- Entitlement.all({:organization => id, :feature_id => feature_id, :provider_name => 'internal' }, @api_key)
23
- end
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
@@ -1,3 +1,3 @@
1
1
  module Nurego
2
- VERSION = '1.0.10'
2
+ VERSION = '1.1.11'
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.0.10
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-25 00:00:00.000000000 Z
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client