Class: Qrdot::QrResource
- Inherits:
-
Object
- Object
- Qrdot::QrResource
- Defined in:
- lib/qrdot/client.rb
Instance Method Summary collapse
- #batch(items, idempotency_key: nil) ⇒ Object
- #create(payload, idempotency_key: nil) ⇒ Object
- #delete(id) ⇒ Object
- #duplicate(id) ⇒ Object
- #export_images(ids, format = "png") ⇒ Object
- #get(id) ⇒ Object
- #image(id, format = "png") ⇒ Object
-
#initialize(client) ⇒ QrResource
constructor
A new instance of QrResource.
- #list(query = {}) ⇒ Object
- #update(id, payload) ⇒ Object
Constructor Details
#initialize(client) ⇒ QrResource
Returns a new instance of QrResource.
90 91 92 |
# File 'lib/qrdot/client.rb', line 90 def initialize(client) @c = client end |
Instance Method Details
#batch(items, idempotency_key: nil) ⇒ Object
105 106 107 108 109 |
# File 'lib/qrdot/client.rb', line 105 def batch(items, idempotency_key: nil) headers = {} headers["Idempotency-Key"] = idempotency_key if idempotency_key @c.request("POST", "/v1/qr/batch", body: { items: items }, headers: headers) end |
#create(payload, idempotency_key: nil) ⇒ Object
94 95 96 97 98 |
# File 'lib/qrdot/client.rb', line 94 def create(payload, idempotency_key: nil) headers = {} headers["Idempotency-Key"] = idempotency_key if idempotency_key @c.request("POST", "/v1/qr", body: payload, headers: headers) end |
#delete(id) ⇒ Object
119 120 121 |
# File 'lib/qrdot/client.rb', line 119 def delete(id) @c.request("DELETE", "/v1/qr/#{URI.encode_www_form_component(id)}") end |
#duplicate(id) ⇒ Object
123 124 125 |
# File 'lib/qrdot/client.rb', line 123 def duplicate(id) @c.request("POST", "/v1/qr/#{URI.encode_www_form_component(id)}/duplicate") end |
#export_images(ids, format = "png") ⇒ Object
131 132 133 |
# File 'lib/qrdot/client.rb', line 131 def export_images(ids, format = "png") @c.request_bytes("POST", "/v1/qr/export/images", body: { ids: ids, format: format }) end |
#get(id) ⇒ Object
111 112 113 |
# File 'lib/qrdot/client.rb', line 111 def get(id) @c.request("GET", "/v1/qr/#{URI.encode_www_form_component(id)}") end |
#image(id, format = "png") ⇒ Object
127 128 129 |
# File 'lib/qrdot/client.rb', line 127 def image(id, format = "png") @c.request_bytes("GET", "/v1/qr/#{URI.encode_www_form_component(id)}/image.#{format}") end |
#list(query = {}) ⇒ Object
100 101 102 103 |
# File 'lib/qrdot/client.rb', line 100 def list(query = {}) qs = query.empty? ? "" : "?#{URI.encode_www_form(query)}" @c.request("GET", "/v1/qr#{qs}") end |
#update(id, payload) ⇒ Object
115 116 117 |
# File 'lib/qrdot/client.rb', line 115 def update(id, payload) @c.request("PATCH", "/v1/qr/#{URI.encode_www_form_component(id)}", body: payload) end |