doohly 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +88 -0
- data/CHANGELOG.md +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +214 -0
- data/Rakefile +12 -0
- data/docs/example/GET_booking_by_id.json +1347 -0
- data/docs/example/GET_bookings.json +20366 -0
- data/docs/example/GET_creative_by_id.json +9 -0
- data/docs/example/GET_device_by_id.json +1268 -0
- data/docs/example/GET_devices.json +2576 -0
- data/docs/example/PUT_creatives.json +4 -0
- data/doohly.gemspec +48 -0
- data/examples/usage.rb +69 -0
- data/lib/doohly/client.rb +252 -0
- data/lib/doohly/configuration.rb +43 -0
- data/lib/doohly/error.rb +36 -0
- data/lib/doohly/version.rb +5 -0
- data/lib/doohly.rb +18 -0
- data/sig/doohly.rbs +4 -0
- data/test_api.rb +26 -0
- metadata +197 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ec0740e7866069798ff27a4b45a33757d8089c6c7ebdb0f7fcc3315ddd7f02a4
|
|
4
|
+
data.tar.gz: bc19baf1010dc9f34cb1c4e2470c5e509de73276515279f5ec755c29f15c60d5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a3ac4751076638654f0c799cb0e3c7524e6bb9ae3fbea2eaac41bae07638b8962e48780912238a6b4311f4a7ffcf70ce8aa85fa9690d928d6ddf6d40af12e0b6
|
|
7
|
+
data.tar.gz: e1703715bb36cca9c54b6e29d09ab385e1e99929a59545ce0eae7cc858d6f56d17962aa5ebf018843fcca09ce118b7d5f7336c28ca04024a6ecec70546b5c712
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.0
|
|
6
|
+
NewCops: enable
|
|
7
|
+
SuggestExtensions: false
|
|
8
|
+
Exclude:
|
|
9
|
+
- 'vendor/**/*'
|
|
10
|
+
- 'tmp/**/*'
|
|
11
|
+
- 'bin/**/*'
|
|
12
|
+
|
|
13
|
+
# Disable problematic cops
|
|
14
|
+
Capybara/RSpec/PredicateMatcher:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
# Style preferences
|
|
18
|
+
Style/StringLiterals:
|
|
19
|
+
Enabled: true
|
|
20
|
+
EnforcedStyle: double_quotes
|
|
21
|
+
|
|
22
|
+
Style/StringLiteralsInInterpolation:
|
|
23
|
+
Enabled: true
|
|
24
|
+
EnforcedStyle: double_quotes
|
|
25
|
+
|
|
26
|
+
Style/Documentation:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
Style/FrozenStringLiteralComment:
|
|
30
|
+
Enabled: true
|
|
31
|
+
EnforcedStyle: always
|
|
32
|
+
|
|
33
|
+
# Layout preferences
|
|
34
|
+
Layout/LineLength:
|
|
35
|
+
Max: 120
|
|
36
|
+
AllowedPatterns: ['\A\s*#']
|
|
37
|
+
|
|
38
|
+
Layout/MultilineMethodCallIndentation:
|
|
39
|
+
Enabled: true
|
|
40
|
+
EnforcedStyle: indented
|
|
41
|
+
|
|
42
|
+
# Metrics
|
|
43
|
+
Metrics/BlockLength:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/**/*'
|
|
46
|
+
- '*.gemspec'
|
|
47
|
+
|
|
48
|
+
Metrics/MethodLength:
|
|
49
|
+
Max: 50
|
|
50
|
+
|
|
51
|
+
Metrics/ClassLength:
|
|
52
|
+
Max: 200
|
|
53
|
+
|
|
54
|
+
Metrics/AbcSize:
|
|
55
|
+
Max: 35
|
|
56
|
+
|
|
57
|
+
Metrics/CyclomaticComplexity:
|
|
58
|
+
Max: 15
|
|
59
|
+
|
|
60
|
+
Metrics/PerceivedComplexity:
|
|
61
|
+
Max: 15
|
|
62
|
+
|
|
63
|
+
Metrics/ParameterLists:
|
|
64
|
+
Max: 15
|
|
65
|
+
|
|
66
|
+
# RSpec specific
|
|
67
|
+
RSpec/ExampleLength:
|
|
68
|
+
Max: 25
|
|
69
|
+
|
|
70
|
+
RSpec/MultipleExpectations:
|
|
71
|
+
Max: 5
|
|
72
|
+
|
|
73
|
+
RSpec/NestedGroups:
|
|
74
|
+
Max: 5
|
|
75
|
+
|
|
76
|
+
RSpec/MultipleDescribes:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
# Gemspec
|
|
80
|
+
Gemspec/DevelopmentDependencies:
|
|
81
|
+
Enabled: false
|
|
82
|
+
|
|
83
|
+
Naming/PredicateMethod:
|
|
84
|
+
Enabled: false
|
|
85
|
+
|
|
86
|
+
# Lint
|
|
87
|
+
Lint/ScriptPermission:
|
|
88
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2025-11-11
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Initial release
|
|
14
|
+
- Support for Doohly API v1 and v2 endpoints
|
|
15
|
+
- Devices API (list, get by ID)
|
|
16
|
+
- Bookings API (list, get, create, update, delete)
|
|
17
|
+
- Creatives API (get signed upload URL, check upload status)
|
|
18
|
+
- Configuration management
|
|
19
|
+
- Comprehensive error handling
|
|
20
|
+
- Full test coverage with RSpec
|
|
21
|
+
- RuboCop linting configuration
|
|
22
|
+
- CI/CD with GitHub Actions
|
|
23
|
+
|
|
24
|
+
[Unreleased]: https://github.com/Sentia/doohly/compare/v0.1.0...HEAD
|
|
25
|
+
[0.1.0]: https://github.com/Sentia/doohly/releases/tag/v0.1.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chayut Orapinpatipat
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Doohly Ruby Client
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/doohly)
|
|
4
|
+
[](https://github.com/Sentia/doohly/actions)
|
|
5
|
+
[](https://codecov.io/gh/Sentia/doohly-ruby)
|
|
6
|
+
|
|
7
|
+
A Ruby client library for the [Doohly](https://dooh.ly) Digital Out-of-Home (DOOH) advertising platform API.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'doohly'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bundle install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or install it yourself as:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
gem install doohly
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Configuration
|
|
32
|
+
|
|
33
|
+
Configure the gem globally:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
require 'doohly'
|
|
37
|
+
|
|
38
|
+
Doohly.configure do |config|
|
|
39
|
+
config.api_token = ENV['DOOHLY_API_TOKEN']
|
|
40
|
+
config.timeout = 30
|
|
41
|
+
config.open_timeout = 10
|
|
42
|
+
# config.logger = Logger.new(STDOUT) # Optional: Enable request logging
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or create a client instance directly:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
client = Doohly::Client.new(api_token: 'your_api_token')
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Devices
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
# List all devices
|
|
56
|
+
devices = client.devices
|
|
57
|
+
puts devices
|
|
58
|
+
|
|
59
|
+
# Get a specific device
|
|
60
|
+
device = client.device('device-id-123')
|
|
61
|
+
puts device['name']
|
|
62
|
+
puts device['isConnected']
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Bookings
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
# List all bookings
|
|
69
|
+
bookings = client.bookings
|
|
70
|
+
|
|
71
|
+
# Filter bookings by status
|
|
72
|
+
active_bookings = client.bookings(status: 'booked')
|
|
73
|
+
|
|
74
|
+
# Get a specific booking
|
|
75
|
+
booking = client.booking('booking-id-123')
|
|
76
|
+
|
|
77
|
+
# Create a new booking
|
|
78
|
+
new_booking = client.create_booking(
|
|
79
|
+
name: 'My Campaign',
|
|
80
|
+
status: 'draft',
|
|
81
|
+
external_id: 'campaign-001',
|
|
82
|
+
plays_per_loop: 2,
|
|
83
|
+
loops_per_play: 1,
|
|
84
|
+
play_consecutively: true,
|
|
85
|
+
purchase_type: 'Sold',
|
|
86
|
+
schedule: {
|
|
87
|
+
startDate: '2024-01-01',
|
|
88
|
+
endDate: '2024-12-31',
|
|
89
|
+
startTime: '09:00:00',
|
|
90
|
+
endTime: '18:00:00',
|
|
91
|
+
days: ['mon', 'tue', 'wed', 'thu', 'fri'],
|
|
92
|
+
timezone: 'America/New_York',
|
|
93
|
+
useLocalTime: false
|
|
94
|
+
},
|
|
95
|
+
assigned_creatives: [
|
|
96
|
+
{
|
|
97
|
+
creative: { id: 'creative-id-123' },
|
|
98
|
+
durationSource: 'custom',
|
|
99
|
+
durationMs: 15000,
|
|
100
|
+
order: 1
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
assigned_frames: [
|
|
104
|
+
{ frame: { id: 'frame-id-456' } }
|
|
105
|
+
],
|
|
106
|
+
seedooh: {
|
|
107
|
+
enabled: false
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Update a booking
|
|
112
|
+
updated_booking = client.update_booking(
|
|
113
|
+
'booking-id-123',
|
|
114
|
+
name: 'Updated Campaign Name',
|
|
115
|
+
status: 'booked'
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# Delete a booking
|
|
119
|
+
result = client.delete_booking('booking-id-123')
|
|
120
|
+
puts "Removed from #{result['removedFromDeviceCount']} devices"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Creatives
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
# Get signed URL for uploading a creative
|
|
127
|
+
upload_info = client.get_signed_upload_url(
|
|
128
|
+
name: 'my-video.mp4',
|
|
129
|
+
mime_type: 'video/mp4',
|
|
130
|
+
file_size: 5_242_880, # 5MB in bytes
|
|
131
|
+
playback_scaling: 'contain',
|
|
132
|
+
path: ['campaigns', '2024']
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
upload_url = upload_info['uploadUrl']
|
|
136
|
+
upload_id = upload_info['id']
|
|
137
|
+
|
|
138
|
+
# Upload the file to the signed URL (using your preferred HTTP client)
|
|
139
|
+
require 'net/http'
|
|
140
|
+
uri = URI(upload_url)
|
|
141
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
142
|
+
http.use_ssl = true
|
|
143
|
+
request = Net::HTTP::Put.new(uri)
|
|
144
|
+
request['Content-Type'] = 'video/mp4'
|
|
145
|
+
request.body = File.read('path/to/my-video.mp4')
|
|
146
|
+
response = http.request(request)
|
|
147
|
+
|
|
148
|
+
# Check upload status
|
|
149
|
+
status = client.creative_upload_status(upload_id)
|
|
150
|
+
puts status['creative']['status'] # 'pending', 'processing', or 'complete'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Error Handling
|
|
154
|
+
|
|
155
|
+
The gem provides specific error classes for different scenarios:
|
|
156
|
+
|
|
157
|
+
```ruby
|
|
158
|
+
begin
|
|
159
|
+
client.device('non-existent-id')
|
|
160
|
+
rescue Doohly::NotFoundError => e
|
|
161
|
+
puts "Device not found: #{e.message}"
|
|
162
|
+
puts "Status: #{e.status}"
|
|
163
|
+
rescue Doohly::AuthenticationError => e
|
|
164
|
+
puts "Authentication failed: #{e.message}"
|
|
165
|
+
rescue Doohly::RateLimitError => e
|
|
166
|
+
puts "Rate limit exceeded: #{e.message}"
|
|
167
|
+
rescue Doohly::APIError => e
|
|
168
|
+
puts "API error: #{e.message}"
|
|
169
|
+
end
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Available error classes:
|
|
173
|
+
- `Doohly::Error` - Base error class
|
|
174
|
+
- `Doohly::ConfigurationError` - Invalid configuration
|
|
175
|
+
- `Doohly::APIError` - Base API error
|
|
176
|
+
- `Doohly::AuthenticationError` - 401 errors
|
|
177
|
+
- `Doohly::NotFoundError` - 404 errors
|
|
178
|
+
- `Doohly::BadRequestError` - 400 errors
|
|
179
|
+
- `Doohly::RateLimitError` - 429 errors
|
|
180
|
+
- `Doohly::ServerError` - 5xx errors
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
185
|
+
|
|
186
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
187
|
+
|
|
188
|
+
### Running Tests
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
bundle exec rspec
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Linting
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
bundle exec rubocop
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Code Coverage
|
|
201
|
+
|
|
202
|
+
Code coverage reports are generated automatically when running tests. Open `coverage/index.html` to view the report.
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
|
|
206
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Sentia/doohly. This project is intended to be a safe, welcoming space for collaboration.
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
211
|
+
|
|
212
|
+
## Code of Conduct
|
|
213
|
+
|
|
214
|
+
Everyone interacting in the Doohly project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Sentia/doohly/blob/main/CODE_OF_CONDUCT.md).
|