Class: Weeblycloud::Account

Inherits:
CloudResource show all
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

#properties

Instance Method Summary collapse

Methods included from Saveable

#[]=, #save, #set_property

Methods inherited from CloudResource

#[], #get_property, #id, #to_s

Constructor Details

#initializeAccount

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

#getObject

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

#get_user(user_id) ⇒ Object

Get a user with a given ID



35
36
37
# File 'lib/weeblycloud/account.rb', line 35

def get_user(user_id)
  return User.new(user_id)
end

#list_plansObject

Returns a iterable of all Plan resources.



40
41
42
43
# File 'lib/weeblycloud/account.rb', line 40

def list_plans
  result = @client.get("plan")
  return result.map { |plan| Plan.new(plan["plan_id"]) }
end