booking_automation 0.1.2
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/.gitignore +18 -0
- data/.rspec +3 -0
- data/.rspec_status +12 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +56 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/booking_automation.gemspec +47 -0
- data/lib/booking_automation/constants.rb +18 -0
- data/lib/booking_automation/version.rb +3 -0
- data/lib/booking_automation.rb +89 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 962b6d00aed91c3195ac3eca6690483ad716eea307f814cc717cc47a4cf0a24d
|
4
|
+
data.tar.gz: 18639908b04ab01a4a932bec46f24d5e3aebb0bfb522eb22cb57b85aa3fe80d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96c8b7f5a36860ad3a3cbf4835d5e25ade66ada5c57613c33950a2e6d56beadfbb6164bddec7e7efc150c3128a0caef1861b5aaf91d7cb6f6c9edd5f86ea187d
|
7
|
+
data.tar.gz: 4d9f8228baae4101dd209889d5a1949adbf593ab1d16224f43ebeb067f997d7bed4510634b1ef9829f5b84e29c6c61fd034b4a31a5af5348c19e3e0c311cc913
|
data/.gitignore
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
/.bundle/
|
13
|
+
/vendor/bundle
|
14
|
+
/lib/bundler/man/
|
15
|
+
Gemfile.lock
|
16
|
+
.ruby-version
|
17
|
+
.ruby-gemset
|
18
|
+
.rvmrc
|
data/.rspec
ADDED
data/.rspec_status
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------- | ------ | --------------- |
|
3
|
+
./spec/booking_automation_client_spec.rb[1:1:1] | passed | 0.00062 seconds |
|
4
|
+
./spec/booking_automation_client_spec.rb[1:2:1] | passed | 0.00023 seconds |
|
5
|
+
./spec/booking_automation_client_spec.rb[1:2:2] | passed | 0.00007 seconds |
|
6
|
+
./spec/booking_automation_client_spec.rb[1:3:1:1] | passed | 0.00544 seconds |
|
7
|
+
./spec/booking_automation_client_spec.rb[1:3:2:1] | passed | 0.0008 seconds |
|
8
|
+
./spec/booking_automation_client_spec.rb[1:4:1:1] | passed | 0.00113 seconds |
|
9
|
+
./spec/booking_automation_client_spec.rb[1:4:2:1] | passed | 0.00076 seconds |
|
10
|
+
./spec/booking_automation_client_spec.rb[1:5:1:1] | passed | 0.00111 seconds |
|
11
|
+
./spec/booking_automation_client_spec.rb[1:5:2:1] | passed | 0.00081 seconds |
|
12
|
+
./spec/booking_automation_spec.rb[1:1] | passed | 0.00037 seconds |
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
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] - 2019-06-30
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- Added ability to list properties
|
15
|
+
- Added ability to fetch individual property
|
16
|
+
- Added ability to show bookings for a property
|
17
|
+
|
18
|
+
### Changed
|
19
|
+
|
20
|
+
### Removed
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Michael Babin
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# BookingAutomation [](https://travis-ci.com/mihilbabin/booking_automation) [](https://badge.fury.io/rb/booking_automation)
|
2
|
+
|
3
|
+
This is a simple wrapper of [BookingAutomation API](https://manage.bookingautomation.com/api/index.html). It allows to fetch data related to properties and bookings created and filter that data as per API docs.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'booking_automation'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install booking_automation
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To use a gem you should allow API Key through your BookingAutomation settings.
|
24
|
+
Wrapper needs you to supply the account API key (auth_token) set at the menu "Settings > Account"
|
25
|
+
Operations involving a specific property need to supply the property key (propKey) set at the menu "Settings > Properties > Link"
|
26
|
+
|
27
|
+
### Sample Code
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
auth_token = '<your-key>'
|
31
|
+
client = BookingAutomation::Client.new auth_token
|
32
|
+
|
33
|
+
client.get_properties # List all account properties
|
34
|
+
|
35
|
+
prop_key = '<property-key>'
|
36
|
+
|
37
|
+
client.get_property(prop_key) # Display individual property data
|
38
|
+
client.get_property(prop_key, includeRooms: true) # Pass parameters as per docs
|
39
|
+
|
40
|
+
client.get_bookings(prop_key) # Get all bookings for given property
|
41
|
+
client.get_bookings(prop_key, includeInvoice: true) # Pass parameters as per docs
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
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.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mihilbabin/booking_automation.
|
53
|
+
|
54
|
+
## License
|
55
|
+
|
56
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'booking_automation'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'booking_automation/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'booking_automation'
|
8
|
+
spec.version = BookingAutomation::VERSION
|
9
|
+
spec.authors = ['Michael Babin']
|
10
|
+
spec.email = ['michaelbabin.eu@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Booking Automation API}
|
13
|
+
spec.description = %q{Bindings for BookingAutomation.com API}
|
14
|
+
spec.homepage = 'https://github.com/mihilbabin/booking_automation'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
23
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
|
24
|
+
else
|
25
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
26
|
+
'public gem pushes.'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = 'exe'
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ['lib']
|
37
|
+
|
38
|
+
# Development dependencies
|
39
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
40
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_development_dependency 'webmock', '~> 3.6'
|
43
|
+
|
44
|
+
# Dependencies
|
45
|
+
spec.add_dependency 'httparty', '~> 0.17.0'
|
46
|
+
spec.add_dependency 'oj', '~> 3.7'
|
47
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BookingAutomation
|
2
|
+
module Constants
|
3
|
+
API_ENDPOINT = 'https://manage.bookingautomation.com/api/json'.freeze
|
4
|
+
|
5
|
+
PARSE_ERROR_MSG = 'Got encoding different from JSON. Please check passed options'.freeze
|
6
|
+
|
7
|
+
DEFAULT_PROPERTY_OPTIONS = {
|
8
|
+
includeRooms: false,
|
9
|
+
includeRoomUnits: false,
|
10
|
+
includeAccountAccess: false
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
DEFAULT_BOOKING_OPTIONS = {
|
14
|
+
includeInvoice: false,
|
15
|
+
includeInfoItems: false
|
16
|
+
}.freeze
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'oj'
|
3
|
+
require 'booking_automation/constants'
|
4
|
+
require 'booking_automation/version'
|
5
|
+
|
6
|
+
module BookingAutomation
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
9
|
+
class APIError < StandardError
|
10
|
+
attr_accessor :response
|
11
|
+
|
12
|
+
def initialize(msg, response)
|
13
|
+
super(msg)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Client
|
19
|
+
include HTTParty
|
20
|
+
base_uri Constants::API_ENDPOINT
|
21
|
+
|
22
|
+
attr_accessor :auth_token
|
23
|
+
|
24
|
+
def initialize(auth_token)
|
25
|
+
@auth_token = auth_token
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_properties
|
29
|
+
response = self.class.post('/getProperties', body: authentication.to_json)
|
30
|
+
json = parse! response
|
31
|
+
json['getProperties']
|
32
|
+
rescue Oj::ParseError
|
33
|
+
raise Error, Constants::PARSE_ERROR_MSG
|
34
|
+
rescue APIError => e
|
35
|
+
e.response
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_property(prop_key, options={})
|
39
|
+
response = self.class.post(
|
40
|
+
'/getProperty',
|
41
|
+
body: payload(prop_key, Constants::DEFAULT_PROPERTY_OPTIONS.merge(options))
|
42
|
+
)
|
43
|
+
json = parse! response
|
44
|
+
json['getProperty'].first
|
45
|
+
rescue Oj::ParseError
|
46
|
+
raise Error, Constants::PARSE_ERROR_MSG
|
47
|
+
rescue APIError => e
|
48
|
+
e.response
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_bookings(prop_key, options={})
|
52
|
+
response = self.class.post(
|
53
|
+
'/getBookings',
|
54
|
+
body: payload(prop_key, Constants::DEFAULT_BOOKING_OPTIONS.merge(options))
|
55
|
+
)
|
56
|
+
parse! response
|
57
|
+
rescue Oj::ParseError
|
58
|
+
raise Error, Constants::PARSE_ERROR_MSG
|
59
|
+
rescue APIError => e
|
60
|
+
e.response
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def authentication(prop_key=nil)
|
66
|
+
{
|
67
|
+
authentication: {
|
68
|
+
apiKey: auth_token,
|
69
|
+
propKey: prop_key
|
70
|
+
}
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def payload(prop_key=nil, options={})
|
75
|
+
authentication(prop_key)
|
76
|
+
.merge(options)
|
77
|
+
.to_json
|
78
|
+
end
|
79
|
+
|
80
|
+
def parse!(response)
|
81
|
+
json = Oj.load response.body
|
82
|
+
raise APIError.new(
|
83
|
+
"API Error: #{json['errorCode']} #{json['error']}",
|
84
|
+
json
|
85
|
+
) if json.is_a?(Hash) && !json['error'].nil?
|
86
|
+
json
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: booking_automation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Babin
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.17.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.17.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: oj
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
description: Bindings for BookingAutomation.com API
|
98
|
+
email:
|
99
|
+
- michaelbabin.eu@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".rspec_status"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- booking_automation.gemspec
|
116
|
+
- lib/booking_automation.rb
|
117
|
+
- lib/booking_automation/constants.rb
|
118
|
+
- lib/booking_automation/version.rb
|
119
|
+
homepage: https://github.com/mihilbabin/booking_automation
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata:
|
123
|
+
homepage_uri: https://github.com/mihilbabin/booking_automation
|
124
|
+
source_code_uri: https://github.com/mihilbabin/booking_automation
|
125
|
+
changelog_uri: https://github.com/mihilbabin/booking_automation/CHANGELOG.md
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubygems_version: 3.0.3
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Booking Automation API
|
145
|
+
test_files: []
|