Class: Megam::EventsMarketplace
Instance Attribute Summary
Attributes inherited from RestAdapter
#api_key, #email, #headers, #host, #master_key, #org_id, #password_hash
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from RestAdapter
#megam_rest
Constructor Details
Returns a new instance of EventsMarketplace.
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/megam/core/eventsmarketplace.rb', line 3
def initialize(o)
@account_id = nil
@marketplace_id = nil
@event_type = nil
@data = []
@created_at = nil
@id = nil
@limit = nil
@some_msg = {}
super(o)
end
|
Class Method Details
.create(params) ⇒ Object
156
157
158
159
|
# File 'lib/megam/core/eventsmarketplace.rb', line 156
def self.create(params)
evt = from_hash(params)
evt.create
end
|
.from_hash(o) ⇒ Object
139
140
141
142
143
|
# File 'lib/megam/core/eventsmarketplace.rb', line 139
def self.from_hash(o)
evt = self.new(o)
evt.from_hash(o)
evt
end
|
.index(params) ⇒ Object
177
178
179
180
|
# File 'lib/megam/core/eventsmarketplace.rb', line 177
def self.index(params)
asm = self.new(params)
asm.megam_rest.index_eventsMarketplace
end
|
.json_create(o) ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/megam/core/eventsmarketplace.rb', line 123
def self.json_create(o)
evt = new({})
evt.account_id(o["account_id"]) if o.has_key?("account_id")
evt.marketplace_id(o["marketplace_id"]) if o.has_key?("marketplace_id")
evt.id(o["id"]) if o.has_key?("id")
evt.event_type(o["event_type"]) if o.has_key?("event_type")
evt.data(o["data"]) if o.has_key?("data")
evt.limit(o["limit"]) if o.has_key?("limit")
evt.created_at(o["created_at"]) if o.has_key?("created_at")
evt.some_msg[:code] = o["code"] if o.has_key?("code")
evt.some_msg[:msg_type] = o["msg_type"] if o.has_key?("msg_type")
evt.some_msg[:msg]= o["msg"] if o.has_key?("msg")
evt.some_msg[:links] = o["links"] if o.has_key?("links")
evt
end
|
.list(params) ⇒ Object
172
173
174
175
|
# File 'lib/megam/core/eventsmarketplace.rb', line 172
def self.list(params)
asm = self.new(params)
asm.megam_rest.list_eventsMarketplace(params[:limit])
end
|
.show(o) ⇒ Object
Load a account by email_p
167
168
169
170
|
# File 'lib/megam/core/eventsmarketplace.rb', line 167
def self.show(o)
evt = from_hash(o)
evt.megam_rest.get_eventsMarketplace(o[:limit], evt.from_hash(o).for_json)
end
|
Instance Method Details
#account_id(arg = nil) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/megam/core/eventsmarketplace.rb', line 19
def account_id(arg=nil)
if arg != nil
@account_id = arg
else
@account_id
end
end
|
#create ⇒ Object
Create the node via the REST API
162
163
164
|
# File 'lib/megam/core/eventsmarketplace.rb', line 162
def create
megam_rest.post_events(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/megam/core/eventsmarketplace.rb', line 67
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#data(arg = []) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/megam/core/eventsmarketplace.rb', line 52
def data(arg=[])
if arg != []
@data = arg
else
@data
end
end
|
#error? ⇒ Boolean
75
76
77
|
# File 'lib/megam/core/eventsmarketplace.rb', line 75
def error?
crocked = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end
|
#event_type(arg = nil) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/megam/core/eventsmarketplace.rb', line 43
def event_type(arg=nil)
if arg != nil
@event_type = arg
else
@event_type
end
end
|
#eventsmarketplace ⇒ Object
15
16
17
|
# File 'lib/megam/core/eventsmarketplace.rb', line 15
def eventsmarketplace
self
end
|
#for_json ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/megam/core/eventsmarketplace.rb', line 110
def for_json
result = {
"account_id" => account_id,
"marketplace_id" => marketplace_id,
"event_type" => event_type,
"data" => data,
"limit" => limit,
"created_at" => created_at,
"id" => id
}
result
end
|
#from_hash(o) ⇒ Object
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/megam/core/eventsmarketplace.rb', line 145
def from_hash(o)
@account_id = o[:account_id] if o.has_key?(:account_id)
@marketplace_id = o[:marketplace_id] if o.has_key?(:marketplace_id)
@event_type = o[:event_type] if o.has_key?(:event_type)
@data = o[:data] if o.has_key?(:data)
@limit = o[:limit] if o.has_key?(:limit)
@created_at = o[:created_at] if o.has_key?(:created_at)
@id = o[:id] if o.has_key?(:id)
self
end
|
#id(arg = nil) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/megam/core/eventsmarketplace.rb', line 27
def id(arg=nil)
if arg != nil
@id = arg
else
@id
end
end
|
#limit(arg = []) ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/megam/core/eventsmarketplace.rb', line 60
def limit(arg=[])
if arg != []
@limit = arg
else
@limit
end
end
|
#marketplace_id(arg = nil) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/megam/core/eventsmarketplace.rb', line 35
def marketplace_id(arg=nil)
if arg != nil
@marketplace_id = arg
else
@marketplace_id
end
end
|
#some_msg(arg = nil) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/megam/core/eventsmarketplace.rb', line 80
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
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/megam/core/eventsmarketplace.rb', line 90
def to_hash
index_hash = Hash.new
index_hash["json_claz"] = self.class.name
index_hash["account_id"] = account_id
index_hash["marketplace_id"] = marketplace_id
index_hash["event_type"] = event_type
index_hash["data"] = data
index_hash["limit"] = limit
index_hash["created_at"] = created_at
index_hash["id"] = id
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.
106
107
108
|
# File 'lib/megam/core/eventsmarketplace.rb', line 106
def to_json(*a)
for_json.to_json(*a)
end
|
#to_s ⇒ Object
182
183
184
|
# File 'lib/megam/core/eventsmarketplace.rb', line 182
def to_s
Megam::Stuff.styled_hash(to_hash)
end
|