Class: Megam::Billedhistories
- Inherits:
-
RestAdapter
- Object
- RestAdapter
- Megam::Billedhistories
- Defined in:
- lib/megam/core/billedhistories.rb
Class Method Summary collapse
- .create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .delete(p_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
- .json_create(o) ⇒ Object
-
.list(params) ⇒ Object
Load all billing histories - returns a BillingHistoriesCollection don't return self.
-
.show(p_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Show a particular billing history by name, Megam::BillingHistory.
Instance Method Summary collapse
- #accounts_id(arg = nil) ⇒ Object
- #assembly_id(arg = nil) ⇒ Object
- #bill_type(arg = nil) ⇒ Object
- #billedhistories ⇒ Object
- #billing_amount(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the billing histories via the REST API.
- #created_at(arg = nil) ⇒ Object
- #currency_type(arg = nil) ⇒ Object
- #error? ⇒ Boolean
- #for_json ⇒ Object
- #from_hash(o) ⇒ Object
- #id(arg = nil) ⇒ Object
-
#initialize(o) ⇒ Billedhistories
constructor
A new instance of Billedhistories.
- #some_msg(arg = nil) ⇒ Object
-
#to_hash ⇒ Object
Transform the ruby obj -> to a Hash.
-
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat.
- #to_s ⇒ Object
Constructor Details
#initialize(o) ⇒ Billedhistories
Returns a new instance of Billedhistories.
3 4 5 6 7 8 9 10 11 12 13 |
# 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 |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
155 156 157 158 |
# 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) ⇒ Object
180 181 182 183 |
# 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) ⇒ Object
138 139 140 141 142 |
# 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) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# 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) ⇒ Object
Load all billing histories - returns a BillingHistoriesCollection don't return self. check if the Megam::BillingHistoriesCollection is returned.
168 169 170 171 |
# 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 |
.show(p_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Show a particular billing history by name, Megam::BillingHistory
175 176 177 178 |
# 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 |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
27 28 29 30 31 32 33 |
# 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) ⇒ Object
35 36 37 38 39 40 41 |
# 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) ⇒ Object
43 44 45 46 47 48 49 |
# 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 ⇒ Object
15 16 17 |
# File 'lib/megam/core/billedhistories.rb', line 15 def billedhistories self end |
#billing_amount(arg = nil) ⇒ Object
51 52 53 54 55 56 57 |
# 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 ⇒ Object
Create the billing histories via the REST API
161 162 163 |
# File 'lib/megam/core/billedhistories.rb', line 161 def create megam_rest.post_billedhistories(to_hash) end |
#created_at(arg = nil) ⇒ Object
67 68 69 70 71 72 73 |
# 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) ⇒ Object
59 60 61 62 63 64 65 |
# 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? ⇒ Boolean
83 84 85 |
# 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 ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 |
# 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) ⇒ Object
144 145 146 147 148 149 150 151 152 153 |
# 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) ⇒ Object
19 20 21 22 23 24 25 |
# 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) ⇒ Object
75 76 77 78 79 80 81 |
# 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 ⇒ Object
Transform the ruby obj -> to a Hash
88 89 90 91 92 93 94 95 96 97 98 99 |
# 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) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
103 104 105 |
# File 'lib/megam/core/billedhistories.rb', line 103 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
185 186 187 |
# File 'lib/megam/core/billedhistories.rb', line 185 def to_s Megam::Stuff.styled_hash(to_hash) end |