3scale_api 1.0.7 → 1.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff1614a78872c23c9f770ece900b9c9a1bb9963
4
- data.tar.gz: 4282f1bba90c89c3a35f6c59c815d62934fe756c
3
+ metadata.gz: 43110c72d3cb7575f9627365eaf647c6c63dc5bf
4
+ data.tar.gz: f1faf5f9037b7e37842a884956fbceb902ce4633
5
5
  SHA512:
6
- metadata.gz: d090343d4890466f9969cf4546d539147a45f34dcc84f0d7364352dfa7e87b5944f9e3d621acff9a95bdb3df383681d996566c8a96c0db532b9c4fd5e0792ad1
7
- data.tar.gz: 4acebf3cd1b5ea33875693b3105f9e3f60a7d4384a73362abde06ea421c3f362b4b6856aa6331841d3d35c8ce128265a4dad67edb7ee301424dd1f5a8fc1c0d1
6
+ metadata.gz: 809defac62f1d20b48fa46794b2f295847892eeba6c5b3a98f75847669be4ff211f6f025a70f76247c3facedf277a72d7d9d585be7dacac12eaf4cebbc18b1b4
7
+ data.tar.gz: 4259cd37432e8fbb7933347e4c77bad17112bcb18f2621710c791c9b09bea821689251c5ed6f90500f977d10576d927b23ff2d69096ea9c5648fa804c04f0dfe
@@ -121,23 +121,50 @@ module Threescale
121
121
 
122
122
  def signup_express(account_plan_id, application_plan_id, email, org_name, password, service_plan_id, username,
123
123
  additional_fields = nil)
124
- params = {:provider_key => @provider_key, :username => username,
125
- :password => password, :email => email, :org_name => org_name, :account_plan_id => account_plan_id,
126
- :service_plan_id => service_plan_id, :application_plan_id => application_plan_id}
124
+ params = {:provider_key => @provider_key, :username => username, :password => password, :email => email,
125
+ :org_name => org_name, :account_plan_id => account_plan_id, :service_plan_id => service_plan_id,
126
+ :application_plan_id => application_plan_id}
127
127
  if (additional_fields)
128
128
  additional_fields.each do |key, value|
129
129
  params[key] = value
130
130
  end
131
131
  end
132
132
  response = @conn.post "/admin/api/signup.xml", params
133
- return false if response.status != 201
134
133
  xml = Nokogiri::XML(response.body)
134
+ result = {
135
+ :success => false
136
+ }
137
+ if response.status == 422
138
+ errors = xml.xpath("//errors/error").map do |error|
139
+ error.text
140
+ end
141
+ result[:errors] = errors
142
+ end
143
+ return result if response.status != 201
144
+ result[:success] = true
145
+
135
146
  account_id = xml.xpath('//account/id').first.text
136
147
  user_id = xml.xpath('//account/users/user/id').text
137
148
  self.approve_account account_id
138
149
  results = self.get_application_list account_id
139
150
  results[0][:user_id] = user_id.to_s
140
- results
151
+ result[:account_info] = results
152
+ end
153
+
154
+ def get_account_plans
155
+ response = @conn.get "/admin/api/account_plans.xml", {:provider_key => @provider_key}
156
+ return false if response.status != 200
157
+ xml = Nokogiri::XML(response.body)
158
+ account_plans = Array.new
159
+ xml.xpath("//plans/plan").map do |account_plan|
160
+ if account_plan.css("state").text == "published"
161
+ account_plans.push({
162
+ :name => account_plan.css("name").text,
163
+ :account_plan_id => account_plan.css("id").text
164
+ })
165
+ end
166
+ end
167
+ account_plans
141
168
  end
142
169
 
143
170
  def create_user(account_id, email, password, username)
@@ -1,3 +1,3 @@
1
1
  module Threescale
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -50,6 +50,7 @@ describe "3scaleApi" do
50
50
  'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
51
51
  'User-Agent'=>'Faraday v0.9.1'}).
52
52
  to_return(:status => 200, :body => "", :headers => {})
53
+
53
54
  @threescale.get_application_keys 'account-id', 'application-id'
54
55
  end
55
56
  end
@@ -99,7 +100,6 @@ describe "3scaleApi" do
99
100
  'Content-Type'=>'application/x-www-form-urlencoded',
100
101
  'User-Agent'=>'Faraday v0.9.1'})
101
102
 
102
-
103
103
  @threescale.generate_application_key 'account-id', 'application-id'
104
104
  end
105
105
  end
@@ -141,6 +141,7 @@ describe "3scaleApi" do
141
141
  stub_request(:get, "http://test-url.test/admin/api/services.xml?provider_key=provider-key").
142
142
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
143
143
  to_return(:status => 200, :body => "", :headers => {})
144
+
144
145
  @threescale.get_services
145
146
  end
146
147
  end
@@ -151,6 +152,7 @@ describe "3scaleApi" do
151
152
  with(:body => {"email"=>"email", "password"=>"password", "provider_key"=>"provider-key", "username"=>"username"},
152
153
  :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
153
154
  to_return(:status => 200, :body => "", :headers => {})
155
+
154
156
  @threescale.create_user "account-id", "email", 'password', 'username'
155
157
  end
156
158
  end
@@ -161,6 +163,7 @@ describe "3scaleApi" do
161
163
  with(:body => {"provider_key"=>"provider-key"},
162
164
  :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
163
165
  to_return(:status => 200, :body => "", :headers => {})
166
+
164
167
  @threescale.activate_user "account-id", "user-id"
165
168
  end
166
169
  end
@@ -171,6 +174,7 @@ describe "3scaleApi" do
171
174
  with(:body => {"provider_key"=>"provider-key"},
172
175
  :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
173
176
  to_return(:status => 200, :body => "", :headers => {})
177
+
174
178
  @threescale.change_role_to_admin "account-id", "user-id"
175
179
  end
176
180
  end
@@ -181,6 +185,7 @@ describe "3scaleApi" do
181
185
  with(:body => {"provider_key"=>"provider-key"},
182
186
  :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
183
187
  to_return(:status => 200, :body => "", :headers => {})
188
+
184
189
  @threescale.change_role_to_member "account-id", "user-id"
185
190
  end
186
191
  end
@@ -207,5 +212,27 @@ describe "3scaleApi" do
207
212
  @threescale.approve_account "account_id"
208
213
  end
209
214
  end
215
+
216
+ describe "signup_express" do
217
+ it "should call admin/api/accounts/account_id/approve.xml" do
218
+ stub_request(:post, "http://test-url.test/admin/api/signup.xml").
219
+ with(:body => {"account_plan_id"=>"account-plan-id", "application_plan_id"=>"application-plan-id", "email"=>"email", "optional"=>"optional", "org_name"=>"org-name", "password"=>"password", "provider_key"=>"provider-key", "service_plan_id"=>"service-plan", "username"=>"username"},
220
+ :headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Faraday v0.9.1'}).
221
+ to_return(:status => 200, :body => "", :headers => {})
222
+
223
+ @threescale.signup_express "account-plan-id", "application-plan-id", "email", "org-name", "password",
224
+ "service-plan", "username", {:optional => 'optional'}
225
+ end
226
+ end
227
+
228
+ describe "get_account_plans" do
229
+ it "should call /admin/api/account_plans.xml" do
230
+ stub_request(:get, "http://test-url.test/admin/api/account_plans.xml?provider_key=provider-key").
231
+ with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
232
+ to_return(:status => 200, :body => "", :headers => {})
233
+
234
+ @threescale.get_account_plans
235
+ end
236
+ end
210
237
  end
211
238
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3scale_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robbie Holmes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem is to be used to interact with 3Scale's API.
14
14
  email: