Class: Doohly::Client
- Inherits:
-
Object
- Object
- Doohly::Client
- Defined in:
- lib/doohly/client.rb
Overview
Main API client for Doohly
Instance Attribute Summary collapse
-
#api_base_url ⇒ Object
readonly
Returns the value of attribute api_base_url.
-
#api_token ⇒ Object
readonly
Returns the value of attribute api_token.
Instance Method Summary collapse
-
#booking(id) ⇒ Hash
GET /v2/bookings/:id.
-
#bookings(status: nil) ⇒ Hash
GET /v2/bookings.
-
#create_booking(name:, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) ⇒ Hash
POST /v2/bookings - Create a new booking.
-
#creative_upload_status(id) ⇒ Hash
GET /v1/library/creatives/upload/:id - Get creative upload status.
-
#delete_booking(id) ⇒ Hash
DELETE /v2/bookings/:id - Delete an existing booking.
-
#device(id) ⇒ Hash
GET /v2/devices/:id.
-
#devices ⇒ Hash
GET /v1/devices.
-
#get_signed_upload_url(name:, mime_type:, file_size:, playback_scaling: nil, path: nil) ⇒ Hash
POST /v1/library/creatives/upload - Get signed upload URL.
-
#initialize(api_token: nil, api_base_url: nil) ⇒ Client
constructor
A new instance of Client.
-
#update_booking(id, name: nil, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) ⇒ Hash
PATCH /v2/bookings/:id - Update an existing booking.
Constructor Details
#initialize(api_token: nil, api_base_url: nil) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 |
# File 'lib/doohly/client.rb', line 12 def initialize(api_token: nil, api_base_url: nil) @api_token = api_token || Doohly.configuration.api_token @api_base_url = api_base_url || Doohly.configuration.api_base_url raise ConfigurationError, "API token is required" if @api_token.nil? || @api_token.empty? @connection = build_connection end |
Instance Attribute Details
#api_base_url ⇒ Object (readonly)
Returns the value of attribute api_base_url.
10 11 12 |
# File 'lib/doohly/client.rb', line 10 def api_base_url @api_base_url end |
#api_token ⇒ Object (readonly)
Returns the value of attribute api_token.
10 11 12 |
# File 'lib/doohly/client.rb', line 10 def api_token @api_token end |
Instance Method Details
#booking(id) ⇒ Hash
GET /v2/bookings/:id
35 36 37 |
# File 'lib/doohly/client.rb', line 35 def booking(id) get("v2/bookings/#{id}") end |
#bookings(status: nil) ⇒ Hash
GET /v2/bookings
26 27 28 29 30 |
# File 'lib/doohly/client.rb', line 26 def bookings(status: nil) params = {} params[:status] = status if status get("v2/bookings", params) end |
#create_booking(name:, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) ⇒ Hash
POST /v2/bookings - Create a new booking
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/doohly/client.rb', line 54 def create_booking(name:, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) body = { name: name } body[:externalId] = external_id if external_id body[:playsPerLoop] = plays_per_loop if plays_per_loop body[:loopsPerPlay] = loops_per_play if loops_per_play body[:playConsecutively] = play_consecutively unless play_consecutively.nil? body[:purchaseType] = purchase_type if purchase_type body[:campaign] = campaign if campaign body[:schedule] = schedule if schedule body[:assignedCreatives] = assigned_creatives if assigned_creatives body[:assignedFrames] = assigned_frames if assigned_frames body[:tags] = if body[:seedooh] = seedooh if seedooh body[:status] = status if status post("v2/bookings", body) end |
#creative_upload_status(id) ⇒ Hash
GET /v1/library/creatives/upload/:id - Get creative upload status
140 141 142 |
# File 'lib/doohly/client.rb', line 140 def creative_upload_status(id) get("v1/library/creatives/upload/#{id}") end |
#delete_booking(id) ⇒ Hash
DELETE /v2/bookings/:id - Delete an existing booking
116 117 118 |
# File 'lib/doohly/client.rb', line 116 def delete_booking(id) delete("v2/bookings/#{id}") end |
#device(id) ⇒ Hash
GET /v2/devices/:id
131 132 133 |
# File 'lib/doohly/client.rb', line 131 def device(id) get("v2/devices/#{id}") end |
#devices ⇒ Hash
GET /v1/devices
124 125 126 |
# File 'lib/doohly/client.rb', line 124 def devices get("v1/devices") end |
#get_signed_upload_url(name:, mime_type:, file_size:, playback_scaling: nil, path: nil) ⇒ Hash
POST /v1/library/creatives/upload - Get signed upload URL
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/doohly/client.rb', line 151 def get_signed_upload_url(name:, mime_type:, file_size:, playback_scaling: nil, path: nil) body = { name: name, mimeType: mime_type, fileSize: file_size } body[:playbackScaling] = playback_scaling if playback_scaling body[:path] = path if path post("v1/library/creatives/upload", body) end |
#update_booking(id, name: nil, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) ⇒ Hash
PATCH /v2/bookings/:id - Update an existing booking
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/doohly/client.rb', line 91 def update_booking(id, name: nil, external_id: nil, plays_per_loop: nil, loops_per_play: nil, play_consecutively: nil, purchase_type: nil, campaign: nil, schedule: nil, assigned_creatives: nil, assigned_frames: nil, tags: nil, seedooh: nil, status: nil) body = {} body[:name] = name if name body[:externalId] = external_id unless external_id.nil? body[:playsPerLoop] = plays_per_loop if plays_per_loop body[:loopsPerPlay] = loops_per_play if loops_per_play body[:playConsecutively] = play_consecutively unless play_consecutively.nil? body[:purchaseType] = purchase_type if purchase_type body[:campaign] = campaign unless campaign.nil? body[:schedule] = schedule if schedule body[:assignedCreatives] = assigned_creatives if assigned_creatives body[:assignedFrames] = assigned_frames if assigned_frames body[:tags] = if body[:seedooh] = seedooh if seedooh body[:status] = status if status patch("v2/bookings/#{id}", body) end |