3scale_api 1.0.3 → 1.0.4
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 +4 -4
- data/lib/3scale_api/3scale/api.rb +25 -1
- data/lib/3scale_api/version.rb +1 -1
- data/spec/3scale_api_spec.rb +40 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff660b340900d42bc0438fe6438d6e1cc3694b90
|
4
|
+
data.tar.gz: 0d8e3f09a89907f5467ae737b2b9c5078c262a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 604a7f3f3b3724232ac3115ba3e32782a7c3d657bdf2eb8f9079a41437aec9bad4206d3e9bbaf2dc536a3507158ee72bc9bfb4a8a2831c97ab45bda6d0528c62
|
7
|
+
data.tar.gz: 4b54b7dc7bae5e4d89dab72f8103b1bb5cea0aa517466e50cfe7c21f34e44c3a798b755077d7563da6cbc77d11aec49249f6f70cab24ebb11f9335e2c19220cc
|
@@ -103,7 +103,6 @@ module Threescale
|
|
103
103
|
results = Array.new
|
104
104
|
response = @conn.get "/admin/api/services.xml", {:provider_key => @provider_key }
|
105
105
|
xml = Nokogiri::XML(response.body)
|
106
|
-
p xml
|
107
106
|
services = xml.xpath("//services/service")
|
108
107
|
services.map do |service|
|
109
108
|
{
|
@@ -118,5 +117,30 @@ module Threescale
|
|
118
117
|
:name => name}
|
119
118
|
response.status == 201
|
120
119
|
end
|
120
|
+
|
121
|
+
def create_user(account_id, email, password, username)
|
122
|
+
response = @conn.post "/admin/api/accounts/#{account_id}/users.xml", {:provider_key => @provider_key,
|
123
|
+
:username => username, :password => password, :email => email}
|
124
|
+
response.status == 201
|
125
|
+
end
|
126
|
+
|
127
|
+
def activate_user(account_id, user_id)
|
128
|
+
response = @conn.put "/admin/api/accounts/#{account_id}/users/#{user_id}/activate.xml", {
|
129
|
+
:provider_key => @provider_key}
|
130
|
+
response.status == 201
|
131
|
+
end
|
132
|
+
|
133
|
+
def change_role_to_admin(account_id, user_id)
|
134
|
+
response = @conn.put "/admin/api/accounts/#{account_id}/users/#{user_id}/admin.xml", {
|
135
|
+
:provider_key => @provider_key}
|
136
|
+
response.status == 201
|
137
|
+
end
|
138
|
+
|
139
|
+
def change_role_to_member(account_id, user_id)
|
140
|
+
response = @conn.put "/admin/api/accounts/#{account_id}/users/#{user_id}/member.xml", {
|
141
|
+
:provider_key => @provider_key}
|
142
|
+
response.status == 201
|
143
|
+
end
|
144
|
+
|
121
145
|
end
|
122
146
|
end
|
data/lib/3scale_api/version.rb
CHANGED
data/spec/3scale_api_spec.rb
CHANGED
@@ -154,5 +154,45 @@ describe "3scaleApi" do
|
|
154
154
|
@threescale.create_account "name", "service-id"
|
155
155
|
end
|
156
156
|
end
|
157
|
+
|
158
|
+
describe "create_user" do
|
159
|
+
it "should call /admin/api/accounts/{account_id}/users.xml" do
|
160
|
+
stub_request(:post, "http://test-url.test/admin/api/accounts/account-id/users.xml").
|
161
|
+
with(:body => {"email"=>"email", "password"=>"password", "provider_key"=>"provider-key", "username"=>"username"},
|
162
|
+
: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
|
+
to_return(:status => 200, :body => "", :headers => {})
|
164
|
+
@threescale.create_user "account-id", "email", 'password', 'username'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe "activate_user" do
|
169
|
+
it "should call /admin/api/accounts/{account_id}/users/{user_id}/activate.xml" do
|
170
|
+
stub_request(:put, "http://test-url.test/admin/api/accounts/account-id/users/user-id/activate.xml").
|
171
|
+
with(:body => {"provider_key"=>"provider-key"},
|
172
|
+
: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
|
+
to_return(:status => 200, :body => "", :headers => {})
|
174
|
+
@threescale.activate_user "account-id", "user-id"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "change_role_to_admin" do
|
179
|
+
it "should call /admin/api/accounts/{account_id}/users/{user_id}/admin.xml" do
|
180
|
+
stub_request(:put, "http://test-url.test/admin/api/accounts/account-id/users/user-id/admin.xml").
|
181
|
+
with(:body => {"provider_key"=>"provider-key"},
|
182
|
+
: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
|
+
to_return(:status => 200, :body => "", :headers => {})
|
184
|
+
@threescale.change_role_to_admin "account-id", "user-id"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe "change_role_to_member" do
|
189
|
+
it "should call /admin/api/accounts/{account_id}/users/{user_id}/member.xml" do
|
190
|
+
stub_request(:put, "http://test-url.test/admin/api/accounts/account-id/users/user-id/member.xml").
|
191
|
+
with(:body => {"provider_key"=>"provider-key"},
|
192
|
+
: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'}).
|
193
|
+
to_return(:status => 200, :body => "", :headers => {})
|
194
|
+
@threescale.change_role_to_member "account-id", "user-id"
|
195
|
+
end
|
196
|
+
end
|
157
197
|
end
|
158
198
|
end
|