Class: Megam::Billedhistories
- Defined in:
- lib/megam/core/billedhistories.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
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(email = nil, api_key = nil, host = nil) ⇒ 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
Methods inherited from ServerAPI
Constructor Details
#initialize(email = nil, api_key = nil, host = nil) ⇒ Billedhistories
Returns a new instance of Billedhistories.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megam/core/billedhistories.rb', line 18 def initialize(email=nil, api_key=nil, host=nil) @id = nil @accounts_id = nil @assembly_id = nil @bill_type = nil @billing_amount = nil @currency_type = nil @created_at = nil @some_msg = {} super(email, api_key, host) end |
Class Method Details
.create(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
170 171 172 173 |
# File 'lib/megam/core/billedhistories.rb', line 170 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
195 196 197 198 |
# File 'lib/megam/core/billedhistories.rb', line 195 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
153 154 155 156 157 |
# File 'lib/megam/core/billedhistories.rb', line 153 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
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/megam/core/billedhistories.rb', line 136 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.
183 184 185 186 |
# File 'lib/megam/core/billedhistories.rb', line 183 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
190 191 192 193 |
# File 'lib/megam/core/billedhistories.rb', line 190 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
42 43 44 45 46 47 48 |
# File 'lib/megam/core/billedhistories.rb', line 42 def accounts_id(arg=nil) if arg != nil @accounts_id= arg else @accounts_id end end |
#assembly_id(arg = nil) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/megam/core/billedhistories.rb', line 50 def assembly_id(arg=nil) if arg != nil @assembly_id = arg else @assembly_id end end |
#bill_type(arg = nil) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/megam/core/billedhistories.rb', line 58 def bill_type(arg=nil) if arg != nil @bill_type = arg else @bill_type end end |
#billedhistories ⇒ Object
30 31 32 |
# File 'lib/megam/core/billedhistories.rb', line 30 def billedhistories self end |
#billing_amount(arg = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/megam/core/billedhistories.rb', line 66 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
176 177 178 |
# File 'lib/megam/core/billedhistories.rb', line 176 def create megam_rest.post_billedhistories(to_hash) end |
#created_at(arg = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/megam/core/billedhistories.rb', line 82 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#currency_type(arg = nil) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/megam/core/billedhistories.rb', line 74 def currency_type(arg=nil) if arg != nil @currency_type = arg else @currency_type end end |
#error? ⇒ Boolean
98 99 100 |
# File 'lib/megam/core/billedhistories.rb', line 98 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/megam/core/billedhistories.rb', line 122 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
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/megam/core/billedhistories.rb', line 159 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
34 35 36 37 38 39 40 |
# File 'lib/megam/core/billedhistories.rb', line 34 def id(arg=nil) if arg != nil @id = arg else @id end end |
#some_msg(arg = nil) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/megam/core/billedhistories.rb', line 90 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
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/megam/core/billedhistories.rb', line 103 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.
118 119 120 |
# File 'lib/megam/core/billedhistories.rb', line 118 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
200 201 202 |
# File 'lib/megam/core/billedhistories.rb', line 200 def to_s Megam::Stuff.styled_hash(to_hash) end |