Class: Megam::Credithistories
- Defined in:
- lib/megam/core/credithistories.rb
Instance Attribute Summary
Attributes inherited from ServerAPI
Class Method Summary collapse
- .create(params) ⇒ Object
- .from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
- .json_create(o) ⇒ Object
-
.list(params) ⇒ Object
Load all credithistories - returns a credithistoriesCollection don’t return self.
-
.show(p_name, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Show a particular credithistories by name, Megam::credithistories.
Instance Method Summary collapse
- #accounts_id(arg = nil) ⇒ Object
- #bill_type(arg = nil) ⇒ Object
-
#create ⇒ Object
Create the credit histories via the REST API.
- #created_at(arg = nil) ⇒ Object
- #credit_amount(arg = nil) ⇒ Object
- #credithistories ⇒ 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) ⇒ Credithistories
constructor
A new instance of Credithistories.
- #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) ⇒ Credithistories
Returns a new instance of Credithistories.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/megam/core/credithistories.rb', line 19 def initialize(email=nil, api_key=nil) @id = nil @accounts_id = nil @bill_type = nil @credit_amount = nil @currency_type = nil @created_at = nil @some_msg = {} super(email, api_key) end |
Class Method Details
.create(params) ⇒ Object
161 162 163 164 |
# File 'lib/megam/core/credithistories.rb', line 161 def self.create(params) acct = from_hash(params,params["email"], params["api_key"]) acct.create end |
.from_hash(o, tmp_email = nil, tmp_api_key = nil) ⇒ Object
145 146 147 148 149 |
# File 'lib/megam/core/credithistories.rb', line 145 def self.from_hash(o,tmp_email=nil, tmp_api_key=nil) cts = self.new(tmp_email,tmp_api_key) cts.from_hash(o) cts end |
.json_create(o) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/megam/core/credithistories.rb', line 128 def self.json_create(o) cts = new cts.id(o["id"]) if o.has_key?("id") cts.accounts_id(o["accounts_id"]) if o.has_key?("accounts_id") cts.bill_type(o["bill_type"]) if o.has_key?("bill_type") cts.credit_amount(o["credit_amount"]) if o.has_key?("credit_amount") cts.currency_type(o["currency_type"]) if o.has_key?("currency_type") cts.created_at(o["created_at"]) if o.has_key?("created_at") #success or error cts.some_msg[:code] = o["code"] if o.has_key?("code") cts.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type") cts.some_msg[:msg]= o["msg"] if o.has_key?("msg") cts.some_msg[:links] = o["links"] if o.has_key?("links") cts end |
.list(params) ⇒ Object
Load all credithistories - returns a credithistoriesCollection don’t return self. check if the Megam::ccredithistoriesCollection is returned.
174 175 176 177 |
# File 'lib/megam/core/credithistories.rb', line 174 def self.list(params) cts = self.new(params["email"], params["api_key"]) cts.megam_rest.get_credithistories end |
.show(p_name, tmp_email = nil, tmp_api_key = nil) ⇒ Object
Show a particular credithistories by name, Megam::credithistories
181 182 183 184 |
# File 'lib/megam/core/credithistories.rb', line 181 def self.show(p_name,tmp_email=nil, tmp_api_key=nil) pre = self.new(tmp_email, tmp_api_key) pre.megam_rest.get_credithistories(p_name) end |
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/megam/core/credithistories.rb', line 43 def accounts_id(arg=nil) if arg != nil @accounts_id= arg else @accounts_id end end |
#bill_type(arg = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/megam/core/credithistories.rb', line 51 def bill_type(arg=nil) if arg != nil @bill_type = arg else @bill_type end end |
#create ⇒ Object
Create the credit histories via the REST API
167 168 169 |
# File 'lib/megam/core/credithistories.rb', line 167 def create megam_rest.post_credithistories(to_hash) end |
#created_at(arg = nil) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/megam/core/credithistories.rb', line 75 def created_at(arg=nil) if arg != nil @created_at = arg else @created_at end end |
#credit_amount(arg = nil) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/megam/core/credithistories.rb', line 59 def credit_amount(arg=nil) if arg != nil @credit_amount = arg else @credit_amount end end |
#credithistories ⇒ Object
30 31 32 |
# File 'lib/megam/core/credithistories.rb', line 30 def credithistories self end |
#currency_type(arg = nil) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/megam/core/credithistories.rb', line 67 def currency_type(arg=nil) if arg != nil @currency_type = arg else @currency_type end end |
#error? ⇒ Boolean
91 92 93 |
# File 'lib/megam/core/credithistories.rb', line 91 def error? crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error") end |
#for_json ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/megam/core/credithistories.rb', line 115 def for_json result = { "id" => id, "accounts_id" => accounts_id, "bill_type" => bill_type, "credit_amount" => credit_amount, "currency_type" => currency_type, "created_at" => created_at } result end |
#from_hash(o) ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'lib/megam/core/credithistories.rb', line 151 def from_hash(o) @id = o[:id] if o.has_key?(:id) @accounts_id = o[:accounts_id] if o.has_key?(:accounts_id) @bill_type = o[:bill_type] if o.has_key?(:bill_type) @credit_amount = o[:credit_amount] if o.has_key?(:credit_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
35 36 37 38 39 40 41 |
# File 'lib/megam/core/credithistories.rb', line 35 def id(arg=nil) if arg != nil @id = arg else @id end end |
#some_msg(arg = nil) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/megam/core/credithistories.rb', line 83 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
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/megam/core/credithistories.rb', line 96 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["bill_type"] = bill_type index_hash["credit_amount"] = credit_amount index_hash["currency_type"] = currency_type index_hash["created_at"] = created_at index_hash["some_msg"] = some_msg index_hash end |
#to_json(*a) ⇒ Object
Serialize this object as a hash: called from JsonCompat. Verify if this called from JsonCompat during testing.
111 112 113 |
# File 'lib/megam/core/credithistories.rb', line 111 def to_json(*a) for_json.to_json(*a) end |
#to_s ⇒ Object
186 187 188 |
# File 'lib/megam/core/credithistories.rb', line 186 def to_s Megam::Stuff.styled_hash(to_hash) end |