Class: ProximityBeacon::Client::Attachments
- Inherits:
-
Object
- Object
- ProximityBeacon::Client::Attachments
- Defined in:
- lib/proximity_beacon/client/attachments.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
Instance Method Summary collapse
- #batch_delete(beacon_name, params = nil) ⇒ Object
- #create(attachment, beacon_name, params = nil) ⇒ Object
- #delete(attachment_name, params = nil) ⇒ Object
-
#initialize(credentials) ⇒ Attachments
constructor
A new instance of Attachments.
- #list(beacon_name, params = nil) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Attachments
Returns a new instance of Attachments.
7 8 9 |
# File 'lib/proximity_beacon/client/attachments.rb', line 7 def initialize(credentials) self.credentials = credentials end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
5 6 7 |
# File 'lib/proximity_beacon/client/attachments.rb', line 5 def credentials @credentials end |
Instance Method Details
#batch_delete(beacon_name, params = nil) ⇒ Object
34 35 36 37 38 |
# File 'lib/proximity_beacon/client/attachments.rb', line 34 def batch_delete(beacon_name, params = nil) uri = URI(PROXIMITY_BEACON_ROOT + beacon_name + "/attachments:batchDelete") response = Request.post(uri, credentials, params) JSON.parse(response.body) end |
#create(attachment, beacon_name, params = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/proximity_beacon/client/attachments.rb', line 19 def create(, beacon_name, params = nil) uri = URI(PROXIMITY_BEACON_ROOT + beacon_name + "/attachments") response = Request.post(uri, credentials, params) { |request| request.body = .to_json request.add_field "Content-Type", "application/json" } Attachment.new(JSON.parse(response.body)) end |
#delete(attachment_name, params = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/proximity_beacon/client/attachments.rb', line 28 def delete(, params = nil) uri = URI(PROXIMITY_BEACON_ROOT + ) response = Request.delete(uri, credentials, params) JSON.parse(response.body) end |
#list(beacon_name, params = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/proximity_beacon/client/attachments.rb', line 11 def list(beacon_name, params = nil) uri = URI(PROXIMITY_BEACON_ROOT + beacon_name + "/attachments") response = Request.get(uri, credentials, params) json = JSON.parse(response.body) = json["attachments"] || [] .map {|| Attachment.new() } end |