Class: Megam::ServerAPI
- Inherits:
-
Object
- Object
- Megam::ServerAPI
- Defined in:
- lib/megam/core/server_api.rb
Overview
Basic HTTP client, with support for adding features via middleware
Direct Known Subclasses
Account, Assemblies, Assembly, Availableunits, Balances, Billedhistories, Billings, CSAR, Components, Credithistories, Discounts, Domains, Invoices, MarketPlace, Organizations, Promos, Request, Sensors, SshKey, Subscriptions
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#org_id ⇒ Object
readonly
Returns the value of attribute org_id.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(o) ⇒ ServerAPI
constructor
Create a Megam REST object.
-
#megam_rest ⇒ Object
Build a megam api client.
Constructor Details
#initialize(o) ⇒ ServerAPI
Create a Megam REST object. The supplied email and api_key is used as the base for all subsequent requests. For example, when initialized with an email, api_key url api.megam.io, a call to get
with ‘accounts’ will make an HTTP GET request to api.megam.io/accounts using the email, api_key
32 33 34 35 36 37 38 |
# File 'lib/megam/core/server_api.rb', line 32 def initialize(o) @email = o[:email] @api_key = o[:api_key] || nil @host = o[:host] @password = o[:password] || nil @org_id = o[:org_id] end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
23 24 25 |
# File 'lib/megam/core/server_api.rb', line 23 def api_key @api_key end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
22 23 24 |
# File 'lib/megam/core/server_api.rb', line 22 def email @email end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
24 25 26 |
# File 'lib/megam/core/server_api.rb', line 24 def host @host end |
#org_id ⇒ Object (readonly)
Returns the value of attribute org_id.
26 27 28 |
# File 'lib/megam/core/server_api.rb', line 26 def org_id @org_id end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
25 26 27 |
# File 'lib/megam/core/server_api.rb', line 25 def password @password end |
Instance Method Details
#megam_rest ⇒ Object
Build a megam api client
Parameters
- api
-
The Megam::API client
44 45 46 47 |
# File 'lib/megam/core/server_api.rb', line 44 def megam_rest = { :email => email || Megam::Config[:email], :api_key => api_key || Megam::Config[:api_key], :org_id => org_id || Megam::Config[:org_id], :password => password || Megam::Config[:password], :host => host || Megam::Config[:host]} Megam::API.new() end |