Class: Weeblycloud::Account
- Inherits:
-
CloudResource
- Object
- CloudResource
- Weeblycloud::Account
- Includes:
- Saveable
- Defined in:
- lib/weeblycloud/account.rb
Overview
Represents an Account resource. cloud-developer.weebly.com/account.html
Instance Attribute Summary
Attributes inherited from CloudResource
Instance Method Summary collapse
-
#create_user(email, properties = {}) ⇒ Object
Creates a ‘User`.
-
#get ⇒ Object
Make an API call to get the resource.
-
#get_plan(plan_id) ⇒ Object
Return the Plan with the given ID.
-
#get_user(user_id) ⇒ Object
Get a user with a given ID.
-
#initialize ⇒ Account
constructor
A new instance of Account.
-
#list_plans ⇒ Object
Returns a iterable of all Plan resources.
Methods included from Saveable
Methods inherited from CloudResource
#[], #get_property, #id, #to_s
Constructor Details
#initialize ⇒ Account
Returns a new instance of Account.
14 15 16 17 |
# File 'lib/weeblycloud/account.rb', line 14 def initialize @endpoint = "account" super() end |
Instance Method Details
#create_user(email, properties = {}) ⇒ Object
Creates a ‘User`. Requires the user’s email, and optionally accepts a hash of additional properties. Returns a ‘User` resource. on success.
28 29 30 31 32 |
# File 'lib/weeblycloud/account.rb', line 28 def create_user(email, properties={}) properties.merge!({"email"=>email}) response = @client.post("user", :content=>properties) return User.new(response.json["user"]["user_id"]) end |
#get ⇒ Object
Make an API call to get the resource
20 21 22 23 |
# File 'lib/weeblycloud/account.rb', line 20 def get response = @client.get(@endpoint) @properties = response.json["account"] end |
#get_plan(plan_id) ⇒ Object
Return the Plan with the given ID.
46 47 48 |
# File 'lib/weeblycloud/account.rb', line 46 def get_plan(plan_id) return Plan.new(plan_id) end |