lib/3scale/api/client.rb in 3scale-api-0.1.3 vs lib/3scale/api/client.rb in 3scale-api-0.1.4
- old
+ new
@@ -34,9 +34,59 @@
extract(collection: 'applications', entity: 'application', from: response)
end
# @api public
# @return [Hash]
+ # @param [Fixnum] id Application ID
+ def show_application(id)
+ find_application(id: id)
+ end
+
+ # @api public
+ # @return [Hash]
+ # @param [Fixnum] id Application ID
+ # @param [String] user_key Application User Key
+ # @param [String] application_id Application App ID
+ def find_application(id: nil, user_key: nil, application_id: nil)
+ params = { application_id: id, user_key: user_key, app_id: application_id }.reject { |_,value| value.nil? }
+ response = http_client.get('/admin/api/applications/find', params: params)
+ extract(entity: 'application', from: response)
+ end
+
+ # @api public
+ # @return [Hash] an Application
+ # @param [Fixnum] plan_id Application Plan ID
+ # @param [Hash] attributes Application Attributes
+ # @option attributes [String] :name Application Name
+ # @option attributes [String] :description Application Description
+ # @option attributes [String] :user_key Application User Key
+ # @option attributes [String] :application_id Application App ID
+ # @option attributes [String] :application_key Application App Key(s)
+ def create_application(account_id, attributes = {}, plan_id: , **rest)
+ body = { plan_id: plan_id }.merge(attributes).merge(rest)
+ response = http_client.post("/admin/api/accounts/#{account_id}/applications", body: body)
+ extract(entity: 'application', from: response)
+ end
+
+ # @api public
+ # @return [Hash] an Account
+ # @param [String] name Account Name
+ # @param [String] username User Username
+ # @param [Hash] attributes User and Account Attributes
+ # @option attributes [String] :email User Email
+ # @option attributes [String] :password User Password
+ # @option attributes [String] :account_plan_id Account Plan ID
+ # @option attributes [String] :service_plan_id Service Plan ID
+ # @option attributes [String] :application_plan_id Application Plan ID
+ def signup(attributes = {}, name: , username: , **rest)
+ body = { org_name: name,
+ username: username }.merge(attributes).merge(rest)
+ response = http_client.post('/admin/api/signup', body: body)
+ extract(entity: 'account', from: response)
+ end
+
+ # @api public
+ # @return [Hash]
# @param [Hash] attributes Service Attributes
# @option attributes [String] :name Service Name
def create_service(attributes)
response = http_client.post('/admin/api/services', body: { service: attributes })
extract(entity: 'service', from: response)