class Megam::Billedhistories

Public Class Methods

create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 155
def self.create(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
    acct = from_hash(o,tmp_email, tmp_api_key, tmp_host)
    acct.create
end
delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 180
def self.delete(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
    pre = self.new(tmp_email,tmp_api_key, tmp_host)
    pre.megam_rest.delete_billedhistory(p_name)
end
from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 138
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
    bal = self.new(tmp_email, tmp_api_key, tmp_host)
    bal.from_hash(o)
    bal
end
json_create(o) click to toggle source
# File lib/megam/core/billedhistories.rb, line 121
def self.json_create(o)
    bal = new({})
    bal.id(o["id"]) if o.has_key?("id")
    bal.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id")
    bal.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
    bal.bill_type(o["bill_type"]) if o.has_key?("bill_type")
    bal.billing_amount(o["billing_amount"]) if o.has_key?("billing_amount")
    bal.currency_type(o["currency_type"]) if o.has_key?("currency_type")
    bal.created_at(o["created_at"]) if o.has_key?("created_at")
    #success or error
    bal.some_msg[:code] = o["code"] if o.has_key?("code")
    bal.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
    bal.some_msg[:msg]= o["msg"] if o.has_key?("msg")
    bal.some_msg[:links] = o["links"] if o.has_key?("links")
    bal
end
list(params) click to toggle source

Load all billing histories - returns a BillingHistoriesCollection don’t return self. check if the Megam::BillingHistoriesCollection is returned.

# File lib/megam/core/billedhistories.rb, line 168
def self.list(params)
    billhistory = self.new(params["email"], params["api_key"], params["host"])
    billhistory.megam_rest.get_billedhistories
end
new(o) click to toggle source
Calls superclass method Megam::RestAdapter::new
# File lib/megam/core/billedhistories.rb, line 3
def initialize(o)
    @id = nil
    @accounts_id = nil
    @assembly_id = nil
    @bill_type = nil
    @billing_amount = nil
    @currency_type = nil
    @created_at = nil
    @some_msg = {}
    super(o)
end
show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil) click to toggle source

Show a particular billing history by name, Megam::BillingHistory

# File lib/megam/core/billedhistories.rb, line 175
def self.show(p_name,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
    pre = self.new(tmp_email,tmp_api_key, tmp_host)
    pre.megam_rest.get_billedhistory(p_name)
end

Public Instance Methods

accounts_id(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 27
def accounts_id(arg=nil)
    if arg != nil
        @accounts_id= arg
    else
        @accounts_id
    end
end
assembly_id(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 35
def assembly_id(arg=nil)
    if arg != nil
        @assembly_id = arg
    else
        @assembly_id
    end
end
bill_type(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 43
def bill_type(arg=nil)
    if arg != nil
        @bill_type = arg
    else
        @bill_type
    end
end
billedhistories() click to toggle source
# File lib/megam/core/billedhistories.rb, line 15
def billedhistories
    self
end
billing_amount(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 51
def billing_amount(arg=nil)
    if arg != nil
        @billing_amount= arg
    else
        @billing_amount
    end
end
create() click to toggle source

Create the billing histories via the REST API

# File lib/megam/core/billedhistories.rb, line 161
def create
    megam_rest.post_billedhistories(to_hash)
end
created_at(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 67
def created_at(arg=nil)
    if arg != nil
        @created_at = arg
    else
        @created_at
    end
end
currency_type(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 59
def currency_type(arg=nil)
    if arg != nil
        @currency_type = arg
    else
        @currency_type
    end
end
error?() click to toggle source
# File lib/megam/core/billedhistories.rb, line 83
def error?
    crocked  = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
for_json() click to toggle source
# File lib/megam/core/billedhistories.rb, line 107
def for_json
    result = {
        "id" => id,
        "accounts_id" => accounts_id,
        "assembly_id" => assembly_id,
        "bill_type" => bill_type,
        "billing_amount" => billing_amount,
        "currency_type" => currency_type,
        "created_at" => created_at
    }
    result
end
from_hash(o) click to toggle source
# File lib/megam/core/billedhistories.rb, line 144
def from_hash(o)
    @id        = o[:id] if o.has_key?(:id)
    @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id)
    @assembly_id   = o[:assembly_id] if o.has_key?(:assembly_id)
    @bill_type     = o[:bill_type] if o.has_key?(:bill_type)
    @billing_amount   = o[:billing_amount] if o.has_key?(:billing_amount)
    @currency_type   = o[:currency_type] if o.has_key?(:currency_type)
    @created_at   = o[:created_at] if o.has_key?(:created_at)
    self
end
id(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 19
def id(arg=nil)
    if arg != nil
        @id = arg
    else
        @id
    end
end
some_msg(arg=nil) click to toggle source
# File lib/megam/core/billedhistories.rb, line 75
def some_msg(arg=nil)
    if arg != nil
        @some_msg = arg
    else
        @some_msg
    end
end
to_hash() click to toggle source

Transform the ruby obj -> to a Hash

# File lib/megam/core/billedhistories.rb, line 88
def to_hash
    index_hash = Hash.new
    index_hash["json_claz"] = self.class.name
    index_hash["id"] = id
    index_hash["accounts_id"] = accounts_id
    index_hash["assembly_id"] = assembly_id
    index_hash["bill_type"] = bill_type
    index_hash["billing_amount"] = billing_amount
    index_hash["currency_type"] = currency_type
    index_hash["created_at"] = created_at
    index_hash
end
to_json(*a) click to toggle source

Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.

# File lib/megam/core/billedhistories.rb, line 103
def to_json(*a)
    for_json.to_json(*a)
end
to_s() click to toggle source
# File lib/megam/core/billedhistories.rb, line 185
def to_s
    Megam::Stuff.styled_hash(to_hash)
end