Class: Qrfy::Resources::Qrs
- Inherits:
-
Base
- Object
- Base
- Qrfy::Resources::Qrs
show all
- Defined in:
- lib/qrfy/resources/qrs.rb
Overview
# Qrs Qrfy Resource
A CRUD interface for the actual Qr API calls.
Instance Attribute Summary
Attributes inherited from Base
#client
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#batch_delete(ids:) ⇒ Object
11
12
13
14
15
|
# File 'lib/qrfy/resources/qrs.rb', line 11
def batch_delete(ids:)
post_request("qrs/batch-delete", body: { ids: ids.map(&:to_i) })
true
end
|
#create(qrs, style: nil, folder_id: nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/qrfy/resources/qrs.rb', line 21
def create(qrs, style: nil, folder_id: nil)
qrs = array_wrap(qrs)
body = { qrs: qrs }
body.merge(style: style) unless style.nil?
body.merge(folder: folder_id) unless folder_id.nil?
response = post_request("qrs", body: body)
array_unwrap(response.body["ids"])
end
|
#delete(id) ⇒ Object
17
18
19
|
# File 'lib/qrfy/resources/qrs.rb', line 17
def delete(id)
batch_delete(ids: array_wrap(id))
end
|
#get(id) ⇒ Object
37
38
39
40
41
|
# File 'lib/qrfy/resources/qrs.rb', line 37
def get(id)
response = get_request("qrs/#{id}")
Qrfy::Objects::Qr.new(response.body)
end
|
#retrieve_image(id, format: :png) ⇒ Object
43
44
45
46
47
|
# File 'lib/qrfy/resources/qrs.rb', line 43
def retrieve_image(id, format: :png)
response = get_request("qrs/#{id}/#{format}")
response.body
end
|
#update(id, params) ⇒ Object
49
50
51
52
53
|
# File 'lib/qrfy/resources/qrs.rb', line 49
def update(id, params)
response = put_request("qrs/#{id}", body: params)
response.body["id"]
end
|