Class: Megam::Subscriptions
Instance Attribute Summary
Attributes inherited from ServerAPI
#api_key, #email, #host, #org_id, #password
Class Method Summary
collapse
-
.create(o, 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(tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Load all subscriptions - returns a subscriptionsCollection don’t return self.
-
.show(p_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Show a particular subscriptions by name, Megam::subscriptions.
Instance Method Summary
collapse
Methods inherited from ServerAPI
#megam_rest
Constructor Details
#initialize(email = nil, api_key = nil, host = nil) ⇒ Subscriptions
Returns a new instance of Subscriptions.
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/megam/core/subscriptions.rb', line 19
def initialize(email=nil, api_key=nil, host=nil)
@id = nil
@accounts_id = nil
@assembly_id = nil
@start_date = nil
@end_date = 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
161
162
163
164
|
# File 'lib/megam/core/subscriptions.rb', line 161
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
|
.from_hash(o, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
145
146
147
148
149
|
# File 'lib/megam/core/subscriptions.rb', line 145
def self.from_hash(o,tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
cts = self.new(tmp_email,tmp_api_key,tmp_host)
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/subscriptions.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.assembly_id(o["assembly_id"]) if o.has_key?("assembly_id")
cts.start_date(o["start_date"]) if o.has_key?("start_date")
cts.end_date(o["end_date"]) if o.has_key?("end_date")
cts.created_at(o["created_at"]) if o.has_key?("created_at")
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(tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Load all subscriptions - returns a subscriptionsCollection don’t return self. check if the Megam::subscriptionsCollection is returned.
174
175
176
177
|
# File 'lib/megam/core/subscriptions.rb', line 174
def self.list(tmp_email=nil, tmp_api_key=nil, tmp_host=nil)
cts = self.new(tmp_email, tmp_api_key, tmp_host)
cts.megam_rest.get_subscriptions
end
|
.show(p_name, tmp_email = nil, tmp_api_key = nil, tmp_host = nil) ⇒ Object
Show a particular subscriptions by name, Megam::subscriptions
181
182
183
184
|
# File 'lib/megam/core/subscriptions.rb', line 181
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_subscriptions(p_name)
end
|
Instance Method Details
#accounts_id(arg = nil) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/megam/core/subscriptions.rb', line 43
def accounts_id(arg=nil)
if arg != nil
@accounts_id= arg
else
@accounts_id
end
end
|
#assembly_id(arg = nil) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/megam/core/subscriptions.rb', line 51
def assembly_id(arg=nil)
if arg != nil
@assembly_id = arg
else
@assembly_id
end
end
|
#create ⇒ Object
Create the subscriptions via the REST API
167
168
169
|
# File 'lib/megam/core/subscriptions.rb', line 167
def create
megam_rest.post_subscriptions(to_hash)
end
|
#created_at(arg = nil) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/megam/core/subscriptions.rb', line 75
def created_at(arg=nil)
if arg != nil
@created_at = arg
else
@created_at
end
end
|
#end_date(arg = nil) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/megam/core/subscriptions.rb', line 67
def end_date(arg=nil)
if arg != nil
@end_date = arg
else
@end_date
end
end
|
#error? ⇒ Boolean
91
92
93
|
# File 'lib/megam/core/subscriptions.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/subscriptions.rb', line 115
def for_json
result = {
"id" => id,
"accounts_id" => accounts_id,
"assembly_id" => assembly_id,
"start_date" => start_date,
"end_date" => end_date,
"created_at" => created_at
}
result
end
|
#from_hash(o) ⇒ Object
151
152
153
154
155
156
157
158
159
|
# File 'lib/megam/core/subscriptions.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)
@assembly_id = o[:assembly_id] if o.has_key?(:assembly_id)
@start_date = o[:start_date] if o.has_key?(:start_date)
@end_date = o[:end_date] if o.has_key?(:end_date)
@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/subscriptions.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/subscriptions.rb', line 83
def some_msg(arg=nil)
if arg != nil
@some_msg = arg
else
@some_msg
end
end
|
#start_date(arg = nil) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/megam/core/subscriptions.rb', line 59
def start_date(arg=nil)
if arg != nil
@start_date = arg
else
@start_date
end
end
|
#subscriptions ⇒ Object
30
31
32
|
# File 'lib/megam/core/subscriptions.rb', line 30
def subscriptions
self
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/subscriptions.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["assembly_id"] = assembly_id
index_hash["start_date"] = start_date
index_hash["end_date"] = end_date
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/subscriptions.rb', line 111
def to_json(*a)
for_json.to_json(*a)
end
|
#to_s ⇒ Object
186
187
188
|
# File 'lib/megam/core/subscriptions.rb', line 186
def to_s
Megam::Stuff.styled_hash(to_hash)
end
|