Class: FimmedUp::Client
Instance Method Summary
collapse
Methods included from Parameters
#each, #like, #limit, #parameters, #where
Methods included from Helpers
#json
Methods included from Request
#get, #patch, #post
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/fimmed_up/client.rb', line 14
def initialize(options={})
merged_options = FimmedUp.options.merge(options)
Configuration::VALID_CONFIG_KEYS.each do |key|
send("#{key}=", merged_options[key])
end
end
|
Instance Method Details
#count ⇒ Object
47
48
49
|
# File 'lib/fimmed_up/client.rb', line 47
def count
self.get("#{resource}/count", parameters, {}).to_i
end
|
#create(args) ⇒ Object
39
40
41
|
# File 'lib/fimmed_up/client.rb', line 39
def create(args)
json(self.post(resource, args, {}))
end
|
#delete(id, args) ⇒ Object
51
52
53
|
# File 'lib/fimmed_up/client.rb', line 51
def delete(id, args)
self.delete("#{resource}/#{id}", args, {})
end
|
#find(id) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/fimmed_up/client.rb', line 25
def find(id)
record = self.get("#{resource}/#{id}", {}, {})
if record != ""
json(record)[0]
else
{ "error" => "Not Found" }
end
end
|
#update(id, args) ⇒ Object
34
35
36
37
|
# File 'lib/fimmed_up/client.rb', line 34
def update(id, args)
record = self.patch("#{resource}/#{id}", args, {})
if record && record != "" then json(record) else { "error" => "Not Found" } end
end
|
#updated_count ⇒ Object
43
44
45
|
# File 'lib/fimmed_up/client.rb', line 43
def updated_count
self.get("#{resource}/updatedtoday/count", parameters, {}).to_i
end
|