bemyguest_sdk 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2016 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
@@ -0,0 +1,43 @@
1
+ BeMyGuestApiv1
2
+ =================
3
+ This API SDK was automatically generated by APIMATIC v2.0
4
+
5
+ How To Configure:
6
+ =================
7
+ The generated code might need to be configured with your API credentials. To do that,
8
+ provide the credentials and configuration values as a constructor parameters for the controllers
9
+
10
+ How To Build:
11
+ =============
12
+ The generated code uses a Ruby gem namely 'unirest'. The reference to this gem is
13
+ already added in the gemspec. Therefore, you will need internet access to resolve
14
+ this dependency.
15
+
16
+ How To Use:
17
+ ===========
18
+ The generated code can be used to build gem, which can then be distributed online.
19
+ Otherwise, you can include the generated code in your project to use directly.
20
+
21
+ Use the following steps to build a gem and use locally
22
+
23
+ 1. Run the build command
24
+ ```
25
+ gem build be_my_guest_apiv_1.gemspec
26
+ ```
27
+
28
+ 2. Run the install command
29
+ ```
30
+ gem install ./be_my_guest_apiv_1-1.0.gem
31
+ ```
32
+
33
+ 3. In your Gemfile add this line
34
+ ```
35
+ gem 'be_my_guest_apiv_1', '~> 1.0'
36
+ ```
37
+
38
+ 4. Now create an instance and use the instance methods, like following.
39
+
40
+ ```
41
+ ctl = BeMyGuestApiv1::ConfigController.new params
42
+ ctl.get_retrieve_config params
43
+ ```
@@ -0,0 +1,23 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+ require 'openssl'
3
+ require 'json'
4
+ require 'unirest'
5
+
6
+ # APIMATIC Helper Files
7
+ require 'be_my_guest_apiv_1/api_helper.rb'
8
+ require 'be_my_guest_apiv_1/api_exception.rb'
9
+ require 'be_my_guest_apiv_1/configuration.rb'
10
+ require 'be_my_guest_apiv_1/be_my_guest_apiv_1_client.rb'
11
+
12
+ # Controllers
13
+ require 'be_my_guest_apiv_1/controllers/config_controller.rb'
14
+ require 'be_my_guest_apiv_1/controllers/bookings_controller.rb'
15
+ require 'be_my_guest_apiv_1/controllers/products_controller.rb'
16
+
17
+ # Models
18
+ require 'be_my_guest_apiv_1/models/update_booking_request.rb'
19
+ require 'be_my_guest_apiv_1/models/check_a_booking_request.rb'
20
+ require 'be_my_guest_apiv_1/models/booking_statuses_enum.rb'
21
+ require 'be_my_guest_apiv_1/models/create_a_booking_request.rb'
22
+ require 'be_my_guest_apiv_1/models/booking_status_enum.rb'
23
+ require 'be_my_guest_apiv_1/models/base_string_enum.rb'
@@ -0,0 +1,21 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class APIException < StandardError
5
+ # value store
6
+ attr_reader :response_code
7
+
8
+ # value store
9
+ attr_reader :response_body
10
+
11
+ # The HTTP response code from the API request
12
+ # @param [String] the reason for raising an exception
13
+ # @param [Numeric] the HTTP response code from the API request
14
+ # @param [Object] the HTTP unprased response from the API request
15
+ def initialize(reason, response_code, response_body)
16
+ super(reason)
17
+ @response_code = response_code
18
+ @response_body = response_body
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,76 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class APIHelper
5
+ # Replaces template parameters in the given url
6
+ # @param [String] The query string builder to replace the template parameters
7
+ # @param [Array] The parameters to replace in the url
8
+ def self.append_url_with_template_parameters(query_builder, parameters)
9
+ # perform parameter validation
10
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
11
+
12
+ # return if there are no parameters to replace
13
+ abort('no parameters to append') if parameters.nil?
14
+
15
+ # iterate and append parameters
16
+ parameters.map do |key, value|
17
+ replace_value = ''
18
+
19
+ if value.nil?
20
+ replace_value = ''
21
+ elsif value.is_a? Enumerable
22
+ replace_value = value.join('/')
23
+ else
24
+ replace_value = value.to_s
25
+ end
26
+
27
+ # find the template parameter and replace it with its value
28
+ query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
29
+ end
30
+
31
+ query_builder
32
+ end
33
+
34
+ # Appends the given set of parameters to the given query string
35
+ # @param [String] The query string builder to replace the template parameters
36
+ # @param [Array] The parameters to append
37
+ def self.append_url_with_query_parameters(query_builder, parameters)
38
+ # perform parameter validation
39
+ raise ArgumentError, 'Given value for parameter \"query_builder\" is invalid.' unless query_builder.is_a? String
40
+
41
+ # return if there are no parameters to replace
42
+ abort('no parameters to append') if parameters.nil?
43
+
44
+ # remove any nil values
45
+ parameters = parameters.reject { |_key, value| value.nil? }
46
+
47
+ # does the query string already has parameters
48
+ has_params = query_builder.include? '?'
49
+ separator = has_params ? '&' : '?'
50
+
51
+ # append query with separator and parameters
52
+ query_builder << separator << URI.unescape(URI.encode_www_form(parameters))
53
+ end
54
+
55
+ # Validates and processes the given Url
56
+ # @param [String] The given Url to process
57
+ # @return [String] Pre-processed Url as string
58
+ def self.clean_url(url)
59
+ # perform parameter validation
60
+ raise ArgumentError, 'Invalid Url.' unless url.is_a? String
61
+
62
+ # ensure that the urls are absolute
63
+ matches = url.match(%r{^(https?:\/\/[^\/]+)})
64
+ raise ArgumentError, 'Invalid Url format.' if matches.nil?
65
+
66
+ # get the http protocol match
67
+ protocol = matches[1]
68
+
69
+ # remove redundant forward slashes
70
+ query = url[protocol.length..-1].gsub(%r{\/\/+}, '/')
71
+
72
+ # return process url
73
+ protocol + query
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,33 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ # Require controllers
4
+ require 'controllers/config_controller.rb'
5
+ require 'controllers/bookings_controller.rb'
6
+ require 'controllers/products_controller.rb'
7
+
8
+ module BeMyGuestApiv1
9
+ class BeMyGuestAPIV1Client
10
+ # Singleton access to config controller
11
+ # @return [ConfigController] Returns the controller instance
12
+ def config
13
+ ConfigController.instance
14
+ end
15
+
16
+ # Singleton access to bookings controller
17
+ # @return [BookingsController] Returns the controller instance
18
+ def bookings
19
+ BookingsController.instance
20
+ end
21
+
22
+ # Singleton access to products controller
23
+ # @return [ProductsController] Returns the controller instance
24
+ def products
25
+ ProductsController.instance
26
+ end
27
+
28
+ # Initializer with authentication and configuration parameters
29
+ def initialize(x_authorization: nil)
30
+ Configuration.x_authorization = x_authorization
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class Configuration
5
+ # The base Uri for API calls
6
+ @base_uri = 'https://api.bemyguest.com.sg'
7
+
8
+ # X-Authorization API KEY Value
9
+ @x_authorization = 'TODO: Replace'
10
+
11
+ # create the getters and setters
12
+ class << self
13
+ attr_accessor :BASE_URI
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,378 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class BookingsController
5
+ @@instance = BookingsController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Updates Booking status information.Newly created booking has status `reserved`. In this status BeMyGuest inventory is not yet deducted.Inventory is locked after changing status of the booking from `reserved` to `waiting` (`confirm` action).When the booking is first created, it is marked as `reserved`. Inventories aren't touched yet. Once the partner decides to confirm the said booking, this is the only time the inventory will be impacted. The booking status will be updated from `reserved` to `waiting`.5 days after the booking date all booking with status `waiting` will be marked `expired`.There's 3rd extra action you may invoke in this method : `resend`. If `confirmationEmailSentAt` value is not null then the confirmation email copy sent o partner will be sent again and the timestamp value of this field will be updated.In response Booking object is returned, for example { "data": { "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75", "totalAmount": "123.98", "currencyCode": "SGD", "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e", "totalAmountRequestCurrency": "369.46", "requestCurrencyCode": "MYR", "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7", "createdAt": "2015-12-21 19:53:23", "updatedAt": "2015-12-21 19:53:23", "arrivalDate": "2016-02-21", "salutation": "Mr.", "firstName": "test", "lastName": "test", "email": "test@126.com", "phone": "123456789", "guests": 2, "children": 0, "partnerReference": "test93828", "confirmationEmailSentAt": null, "confirmationEmailFiles": [], "status": "reserved", "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore", "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore", "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b" } }### Parameters+ uuid (required,string) - UUID of booking+ status (string) - Status "confirm" or "cancel"
12
+ # @param [String] status Required parameter: New status of the booking, one of [confirm, cancel, resend]
13
+ # @param [String] uuid Required parameter: UUID of booking
14
+ # @param [UpdateBookingRequest] data Optional parameter: TODO: type description here
15
+ # @return UpdateBookingStatusResponse response from the API call
16
+ def update_booking_status(status, uuid, data = nil)
17
+ # the base uri for api requests
18
+ query_builder = Configuration.base_uri.dup
19
+
20
+ # prepare query string for API call
21
+ query_builder << '/v1/bookings/{uuid}/{status}'
22
+
23
+ # process optional query parameters
24
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
25
+ 'status' => status,
26
+ 'uuid' => uuid
27
+ }
28
+
29
+ # validate and preprocess url
30
+ query_url = APIHelper.clean_url query_builder
31
+
32
+ # prepare headers
33
+ headers = {
34
+ 'user-agent' => 'BeMyGuest.SDK.v1',
35
+ 'accept' => 'application/json',
36
+ 'content-type' => 'application/json; charset=utf-8',
37
+ 'X-Authorization' => Configuration.x_authorization
38
+ }
39
+
40
+ # invoke the API call request to fetch the response
41
+ response = Unirest.put query_url, headers: headers, parameters: data.to_json
42
+
43
+ # Error handling using HTTP status codes
44
+ if response.code == 400
45
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
46
+ elsif response.code == 401
47
+ raise APIException.new 'Unauthorized', 401, response.raw_body
48
+ elsif response.code == 403
49
+ raise APIException.new 'Forbidden', 403, response.raw_body
50
+ elsif response.code == 404
51
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
52
+ elsif response.code == 405
53
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
54
+ elsif response.code == 410
55
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
56
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
57
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
58
+ end
59
+
60
+ response.body
61
+ end
62
+
63
+ # Creates a new booking.
64
+ # Newly created booking has always `reserved` status. It means it's not payed yet, not confirmed by partner but it's created and reserved in BeMyGuest database.
65
+ # After creating a booking partner can do perform two scenarios:
66
+ # - either confirm booking - it means it's been paid by client to partner
67
+ # - ..or cancel
68
+ # After succesfull request - new booking object will be returned with status `waiting`.
69
+ # If you try to create new booking with the same `partnerReference` value as before you will get `GEN-FORBIDDEN` / `403` / `Booking with this partnerReference already exists` error in response.
70
+ # If you try to create a new booking with the total amount (in SGD) higher than the current available credit `walletAvailableBalance` value as before you will get `GEN-FORBIDDEN` / `403` / `Wallet balance too low to create a booking. Current balance: -90.98` error in response.
71
+ # If the product has timeslots, the `timeslotUUID` of the product is REQUIRED in `Check a Booking` and `Create a new booking` methods. Otherwise, it can be excluded.
72
+ # Please remember that with all Booking requests you need to providea proper Content-Type header.
73
+ # `Content-Type: application/json`
74
+ # Example JSON request:
75
+ # {
76
+ # "salutation": "Mr.",
77
+ # "firstName": "Daryle",
78
+ # "lastName": "De Silva",
79
+ # "email": "daryle@bemyguest.com.sg",
80
+ # "phone": "+6591591923",
81
+ # "message": "Hello",
82
+ # "productTypeUuid": "9d4b4d76-5b54-5407-b2d9-e6c021cc472e",
83
+ # "pax": 2,
84
+ # "children": 3,
85
+ # "timeSlotUuid": "b02ae425-421f-5edf-a880-4104c0245dac",
86
+ # "addons": [
87
+ # {
88
+ # "uuid": "37e0f490-d31d-521b-b1f0-95c6e4e38d4c",
89
+ # "quantity": "1"
90
+ # },
91
+ # {
92
+ # "uuid": "a50090e3-567d-5743-9d87-e9d261aad0a9",
93
+ # "quantity": "2"
94
+ # }
95
+ # ],
96
+ # "arrivalDate": "2015-06-07",
97
+ # "partnerReference" : "REF-001",
98
+ # "usePromotion": false
99
+ # }
100
+ # Example JSON response:
101
+ # {
102
+ # "data": {
103
+ # "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75",
104
+ # "totalAmount": "123.98",
105
+ # "currencyCode": "SGD",
106
+ # "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e",
107
+ # "totalAmountRequestCurrency": "369.46",
108
+ # "requestCurrencyCode": "MYR",
109
+ # "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7",
110
+ # "createdAt": "2015-12-21 19:53:23",
111
+ # "updatedAt": "2015-12-21 19:53:23",
112
+ # "arrivalDate": "2016-02-21",
113
+ # "salutation": "Mr.",
114
+ # "firstName": "test",
115
+ # "lastName": "test",
116
+ # "email": "test@126.com",
117
+ # "phone": "123456789",
118
+ # "guests": 2,
119
+ # "children": 0,
120
+ # "partnerReference": "test93828",
121
+ # "confirmationEmailSentAt": null,
122
+ # "confirmationEmailFiles": [],
123
+ # "status": "reserved",
124
+ # "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore",
125
+ # "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore",
126
+ # "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b"
127
+ # }
128
+ # }
129
+ # Example JSON error message when Wallet balance is lower than the new booking :
130
+ # {
131
+ # "error": {
132
+ # "code": "GEN-FORBIDDEN",
133
+ # "http_code": 403,
134
+ # "message": "Wallet balance too low to create a booking. Current balance: -90.98"
135
+ # }
136
+ # }
137
+ # @param [CreateABookingRequest] body Required parameter: TODO: type description here
138
+ # @return CreateABookingResponse response from the API call
139
+ def create_a_booking(body)
140
+ # the base uri for api requests
141
+ query_builder = Configuration.base_uri.dup
142
+
143
+ # prepare query string for API call
144
+ query_builder << '/v1/bookings'
145
+
146
+ # validate and preprocess url
147
+ query_url = APIHelper.clean_url query_builder
148
+
149
+ # prepare headers
150
+ headers = {
151
+ 'user-agent' => 'BeMyGuest.SDK.v1',
152
+ 'accept' => 'application/json',
153
+ 'content-type' => 'application/json; charset=utf-8',
154
+ 'X-Authorization' => Configuration.x_authorization
155
+ }
156
+
157
+ # invoke the API call request to fetch the response
158
+ response = Unirest.post query_url, headers: headers, parameters: body.to_json
159
+
160
+ # Error handling using HTTP status codes
161
+ if response.code == 400
162
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
163
+ elsif response.code == 401
164
+ raise APIException.new 'Unauthorized', 401, response.raw_body
165
+ elsif response.code == 403
166
+ raise APIException.new 'Forbidden', 403, response.raw_body
167
+ elsif response.code == 404
168
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
169
+ elsif response.code == 405
170
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
171
+ elsif response.code == 410
172
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
173
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
174
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
175
+ end
176
+
177
+ response.body
178
+ end
179
+
180
+ # Get a list of bookings.A request can take these parameters:+ `date_start`: As compared with arrivalDate, format YYYY-MM-DD+ `date_end`: As compared with arrivalDate, format YYYY-MM-DD+ `first_name`: Guest's first name+ `last_name`: Guest's last name+ `email`: Guest's email address+ `phone`: Guest's contact number+ `partner_reference`: The given unique partnerReference ID of this booking.+ `page`: Page number for results+ `per_page`: How many results per page - if not provided default value from user account will be used+ `query`: Free phrase for text search for example &query=John###ResponseA response object has the following attributes: + `uuid` - UUID of the booking+ `totalAmount` - Total amount of the booking+ `currencyCode` - Currency code used in this booking+ `currencyUuid` - UUID of the `currencyCode`+ `totalAmountRequestCurrency` - Total amount of the booking in the requested currency. (The requested currency is set in user's profile).+ `requestCurrencyCode` - Currency used by `totalAmountRequestCurrency`+ `requestCurrencyUuid` - UUID of the requested currency+ `createdAt` - The booking's created date+ `updatedAt` - The last updated date+ `arrivalDate` - The arrival date+ `salutation` - Available salutation title: "Mr.", "Ms.", "Mrs."+ `firstName` - Guest's first name+ `lastName` - Guest's last name+ `email` - Guest's email address+ `phone` - Guest's contact number+ `guests` - Number of guests(adults) in this booking+ `children` - Number of children in this booking+ `partnerReference` - The given unique partnerReference ID of this booking.+ `confirmationEmailSentAt` - The sent out time of theconfirmation email + `confirmationEmailFiles` - The confirmation email files of this booking+ `status` - The booking status+ `productTypeTitle` - The productType's title of this booking+ `productTypeTitleTranslated` - The translated productType's title of this booking+ `productTypeUuid` - The productType UUID of this booking.
181
+ # @param [String] date_end Optional parameter: As compared with arrivalDate, format YYYY-MM-DD
182
+ # @param [String] date_start Optional parameter: As compared with arrivalDate, format YYYY-MM-DD
183
+ # @param [String] email Optional parameter: Guest's email address
184
+ # @param [String] first_name Optional parameter: Guest's first name
185
+ # @param [String] last_name Optional parameter: Guest's last name
186
+ # @param [String] page Optional parameter: Page number for results
187
+ # @param [String] partner_reference Optional parameter: The given unique partnerReference ID of this booking
188
+ # @param [String] per_page Optional parameter: How many results per page - if not provided default value from user account will be used
189
+ # @param [String] phone Optional parameter: Guest's contact number
190
+ # @param [String] query Optional parameter: Free phrase for text search for example &query=John
191
+ # @param [BookingStatusesEnum] status Optional parameter: Filter bookings by status reserved|waiting|cancelled|approved|expired|rejected|released|refunded
192
+ # @return GetBookingsResponse response from the API call
193
+ def get_bookings(date_end = nil, date_start = nil, email = nil, first_name = nil, last_name = nil, page = nil, partner_reference = nil, per_page = nil, phone = nil, query = nil, status = nil)
194
+ # the base uri for api requests
195
+ query_builder = Configuration.base_uri.dup
196
+
197
+ # prepare query string for API call
198
+ query_builder << '/v1/bookings/'
199
+
200
+ # process optional query parameters
201
+ query_builder = APIHelper.append_url_with_query_parameters query_builder, {
202
+ 'date_end' => date_end,
203
+ 'date_start' => date_start,
204
+ 'email' => email,
205
+ 'first_name' => first_name,
206
+ 'last_name' => last_name,
207
+ 'page' => page,
208
+ 'partner_reference' => partner_reference,
209
+ 'per_page' => per_page,
210
+ 'phone' => phone,
211
+ 'query' => query,
212
+ 'status' => status
213
+ }
214
+
215
+ # validate and preprocess url
216
+ query_url = APIHelper.clean_url query_builder
217
+
218
+ # prepare headers
219
+ headers = {
220
+ 'user-agent' => 'BeMyGuest.SDK.v1',
221
+ 'accept' => 'application/json',
222
+ 'X-Authorization' => Configuration.x_authorization
223
+ }
224
+
225
+ # invoke the API call request to fetch the response
226
+ response = Unirest.get query_url, headers: headers
227
+
228
+ # Error handling using HTTP status codes
229
+ if response.code == 400
230
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
231
+ elsif response.code == 401
232
+ raise APIException.new 'Unauthorized', 401, response.raw_body
233
+ elsif response.code == 403
234
+ raise APIException.new 'Forbidden', 403, response.raw_body
235
+ elsif response.code == 404
236
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
237
+ elsif response.code == 405
238
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
239
+ elsif response.code == 410
240
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
241
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
242
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
243
+ end
244
+
245
+ response.body
246
+ end
247
+
248
+ # `Check if booking is possible` method request requires lesser parameters as compared to `Create a booking`.In fact before creating a booking we advise to run this request first:- it will check if booking can be made without writing any data in BMG database- it will provide a correct total amount for selected services- if partner is caching products this should be used just before creating a booking - so any differences in cached prices (on partner side) and current price for total amount can be discovered- if partner discover difference in provided total amount then he can act accordingly in his user/client interface (for example - ask customer to accept final changed price)The main difference is that no booking is created in the system and some fields in response JSON object have NULL values. If the product has timeslots, the `timeslotUUID` of the product is REQUIRED in `Check a Booking` and `Create a new booking` methods. Otherwise, it can be excluded.For `booking check` request you don't have to pass customer's data or `partnerReference`.Example JSON request: { "productTypeUuid": "9d4b4d76-5b54-5407-b2d9-e6c021cc472e", "pax": 2, "children": 3, "timeSlotUuid": "b02ae425-421f-5edf-a880-4104c0245dac", "addons": [ { "uuid": "37e0f490-d31d-521b-b1f0-95c6e4e38d4c", "quantity": "1" }, { "uuid": "a50090e3-567d-5743-9d87-e9d261aad0a9", "quantity": "2" } ], "arrivalDate": "2015-06-07", "usePromotion": false }Response example: { "data": { "uuid": null, "totalAmount": "123.98", "currencyCode": "SGD", "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e", "totalAmountRequestCurrency": "369.46", "requestCurrencyCode": "MYR", "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7", "createdAt": null, "updatedAt": null, "arrivalDate": "2015-06-07", "salutation": null, "firstName": null, "lastName": null, "email": null, "phone": null, "guests": 2, "children": 3, "partnerReference": null, "confirmationEmailSentAt": null, "confirmationEmailFiles": [], "status": null, "productTypeTitle": null, "productTypeTitleTranslated": null, "productTypeUuid": "9d4b4d76-5b54-5407-b2d9-e6c021cc472e" } }
249
+ # @param [CheckABookingRequest] body Required parameter: TODO: type description here
250
+ # @return CheckABookingResponse response from the API call
251
+ def create_check_a_booking(body)
252
+ # the base uri for api requests
253
+ query_builder = Configuration.base_uri.dup
254
+
255
+ # prepare query string for API call
256
+ query_builder << '/v1/bookings/check'
257
+
258
+ # validate and preprocess url
259
+ query_url = APIHelper.clean_url query_builder
260
+
261
+ # prepare headers
262
+ headers = {
263
+ 'user-agent' => 'BeMyGuest.SDK.v1',
264
+ 'accept' => 'application/json',
265
+ 'content-type' => 'application/json; charset=utf-8',
266
+ 'X-Authorization' => Configuration.x_authorization
267
+ }
268
+
269
+ # invoke the API call request to fetch the response
270
+ response = Unirest.post query_url, headers: headers, parameters: body.to_json
271
+
272
+ # Error handling using HTTP status codes
273
+ if response.code == 400
274
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
275
+ elsif response.code == 401
276
+ raise APIException.new 'Unauthorized', 401, response.raw_body
277
+ elsif response.code == 403
278
+ raise APIException.new 'Forbidden', 403, response.raw_body
279
+ elsif response.code == 404
280
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
281
+ elsif response.code == 405
282
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
283
+ elsif response.code == 410
284
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
285
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
286
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
287
+ end
288
+
289
+ response.body
290
+ end
291
+
292
+ # Get Booking status information.
293
+ # Possible status return values:
294
+ # - `reserved` - booking created but not confirmed by partner
295
+ # - `waiting` - booking confirmed by partner (for example payed on partned side)
296
+ # - `approved` - booking confirmed by supplier
297
+ # - `cancelled` - cancelled by partner or BeMyGuest
298
+ # - `expired` - no action has been done by supplier or BeMyGuest and booking has expired
299
+ # - `rejected` - supplier rejected booking
300
+ # In response Booking object is returned, for example
301
+ # {
302
+ # "data": {
303
+ # "uuid": "c53cbc74-1efa-58bb-afef-750afc52cd75",
304
+ # "totalAmount": "123.98",
305
+ # "currencyCode": "SGD",
306
+ # "currencyUuid": "cd15153e-dfd1-5039-8aa3-115bec58e86e",
307
+ # "totalAmountRequestCurrency": "369.46",
308
+ # "requestCurrencyCode": "MYR",
309
+ # "requestCurrencyUuid": "e98aaf89-ae5a-5c11-859a-b36f2c8e13c7",
310
+ # "createdAt": "2015-12-21 19:53:23",
311
+ # "updatedAt": "2015-12-21 19:53:23",
312
+ # "arrivalDate": "2016-02-21",
313
+ # "salutation": "Mr.",
314
+ # "firstName": "test",
315
+ # "lastName": "test",
316
+ # "email": "test@126.com",
317
+ # "phone": "123456789",
318
+ # "guests": 2,
319
+ # "children": 0,
320
+ # "partnerReference": "test93828",
321
+ # "confirmationEmailSentAt": null,
322
+ # "confirmationEmailFiles": [],
323
+ # "status": "reserved",
324
+ # "productTypeTitle": "14% OFF for Family: E-Ticket to Universal Studios Singapore",
325
+ # "productTypeTitleTranslated": "14% OFF for Family: E-Ticket to Universal Studios Singapore",
326
+ # "productTypeUuid": "9b967f1a-89c2-5083-a758-e359deb2af9b"
327
+ # }
328
+ # }
329
+ # ###Parameters
330
+ # + uuid (required,string) - UUID of booking
331
+ # @param [String] uuid Required parameter: UUID of booking
332
+ # @return GetBookingStatusResponse response from the API call
333
+ def get_booking_status(uuid)
334
+ # the base uri for api requests
335
+ query_builder = Configuration.base_uri.dup
336
+
337
+ # prepare query string for API call
338
+ query_builder << '/v1/bookings/{uuid}'
339
+
340
+ # process optional query parameters
341
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
342
+ 'uuid' => uuid
343
+ }
344
+
345
+ # validate and preprocess url
346
+ query_url = APIHelper.clean_url query_builder
347
+
348
+ # prepare headers
349
+ headers = {
350
+ 'user-agent' => 'BeMyGuest.SDK.v1',
351
+ 'accept' => 'application/json',
352
+ 'X-Authorization' => Configuration.x_authorization
353
+ }
354
+
355
+ # invoke the API call request to fetch the response
356
+ response = Unirest.get query_url, headers: headers
357
+
358
+ # Error handling using HTTP status codes
359
+ if response.code == 400
360
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
361
+ elsif response.code == 401
362
+ raise APIException.new 'Unauthorized', 401, response.raw_body
363
+ elsif response.code == 403
364
+ raise APIException.new 'Forbidden', 403, response.raw_body
365
+ elsif response.code == 404
366
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
367
+ elsif response.code == 405
368
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
369
+ elsif response.code == 410
370
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
371
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
372
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
373
+ end
374
+
375
+ response.body
376
+ end
377
+ end
378
+ end
@@ -0,0 +1,53 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class ConfigController
5
+ @@instance = ConfigController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # A Config object has the following attributes:+ `timezone` - Our sever timezone+ `now` - Our server timestamp+ `version` - Current version is "1.0"+ `serverUrl` - Main API URL+ `photosUrl` - Base Path to server where we store our images+ `productsSorting` - Available Products lists sorting options (can be combined with commas, for example &sort=date,-price ) + `date` - Date ascending + `-date` - Date descending + `price` - Price ascending + `-price` - Price descending + `distance` - Distance ascending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise) + `-distance` - Distance descending (works only if `latitude`,`longitude` & `distance` parameters are provided, ignored otherwise)+ user - All important userdata for provided API key + `name` - Name / Company / Organization + `email` - E-Mail Address + `uuid` - Unique ID + `continueUrl` - Continue URL (not in use now) + `notifyUrl` - Notify URL (not in use now) + `suggestedMarkup` - Suggested markup, % decimal value, for example 7.5 + `defaultPagination` - Default Pagination value (per page), between 1-100 + `defaultSortBy` - Default sort by for /products (if not specified) + `defaultCurrencyUuid` - Default currency UUID for /products (if not specified) + `defaultCurrencyCode` - Default currency code for /products (if not specified) + `defaultLanguageUuid` - Default language UUID /products (if not specified) + `defaultLanguageCode` - Default language code /products (if not specified) + `walletBalance` - Partner's available wallet balance, based on his deposits + `walletAvailableBalance` - Wallet balance which is a combination of partner's deposit and assigned credit amount + `wallet_alert_value` - Threshold value in SGD, when `walletBallance` reach this value then BMG and partner will be notified on this event+ `languages` - A list of supported languages.+ `currencies` - An array of supported currencies.+ `types` - An array of supported products types.+ `categories` - A tree of supported product categories.+ `locations` - A tree of supported locations. (Continent -> Country -> State -> City)
12
+ # @return RetrieveConfigResponse response from the API call
13
+ def retrieve_config
14
+ # the base uri for api requests
15
+ query_builder = Configuration.base_uri.dup
16
+
17
+ # prepare query string for API call
18
+ query_builder << '/v1/config'
19
+
20
+ # validate and preprocess url
21
+ query_url = APIHelper.clean_url query_builder
22
+
23
+ # prepare headers
24
+ headers = {
25
+ 'user-agent' => 'BeMyGuest.SDK.v1',
26
+ 'accept' => 'application/json',
27
+ 'X-Authorization' => Configuration.x_authorization
28
+ }
29
+
30
+ # invoke the API call request to fetch the response
31
+ response = Unirest.get query_url, headers: headers
32
+
33
+ # Error handling using HTTP status codes
34
+ if response.code == 400
35
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
36
+ elsif response.code == 401
37
+ raise APIException.new 'Unauthorized', 401, response.raw_body
38
+ elsif response.code == 403
39
+ raise APIException.new 'Forbidden', 403, response.raw_body
40
+ elsif response.code == 404
41
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
42
+ elsif response.code == 405
43
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
44
+ elsif response.code == 410
45
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
46
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
47
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
48
+ end
49
+
50
+ response.body
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,161 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class ProductsController
5
+ @@instance = ProductsController.new
6
+ # Singleton instance of the controller class
7
+ def self.instance
8
+ @@instance
9
+ end
10
+
11
+ # Get information about product using its UUID as parameter.###Response+ `uuid` - UUID of product+ `published` - true / false+ `title` - Title of product. Everytime on English+ `titleTranslated` - Title of product on requested language+ `description` - Description of product. Everytime on English+ `descriptionTranslated` - Description of product on requested language+ `highlights` - Highlights of product. Everytime on English+ `highlightsTranslated` - Highlights of product on requested language+ `additionalInfo` - Additional information of product. Everytime on English+ `additionalInfoTranslated` - Additional information of product on requested language+ `priceIncludes` - What's included in product price+ `priceIncludesTranslated` - Translated version of `priceIncludes`+ `itinerary` - Activity itinerary - only applicable for Package type, will be `NULL` for others+ `itineraryTranslated` - translated version of itinerary+ `warnings` - Warnings of the activity (related to safety and insurance)+ `warningsTranslated` - translated version of warnings+ `safety` - activity safety information+ `safetyTranslated` - translated version of safety information+ `latitude` - Latitude+ `longitude` - Longitude+ `minPax` - Minimum number of pax+ `maxPax` - Maximum number of pax+ `basePrice` - Base price of product (for list only)+ `currency` - Currency+ `isFlatPaxPrice` - `true/false` (An indication to tell if the `Product` has the same price for each pax in all of its `productTypes`)+ `reviewCount` - Number of reviews+ `reviewAverageScore` - Average score+ `typeName` - Type of product+ `typeUuid` - Type UUID+ `businessHoursFrom` - supplier business hours `from`+ `businessHoursTo` - supplier business hours `to`+ `meetingTime` - meeting time+ `hotelPickup` - false+ `meetingLocation` - instructions about meeting location with supplier+ `meetingLocationTranslated` - translated version of meeting location+ `photosUrl` - Base URL for images+ `photos` - Array of photos in different dimensions (Sizes: original, 75x50, 175x112, 680x325)+ `categories` - Array of categories+ `productTypes` + `uuid` - UUID of Product Type + `title` - Title of Product Type + `titleTranslated` - Translated version of title + `description` - Description of Product Type + `descriptionTranslated` - translated version of description + `durationDays` - duration in days + `durationHours` - duration in hours + `durationMinutes` - duration in minutes + `paxMin` - Minimum number of people + `paxMax` - Maximum number of people + `daysInAdvance` - how many days in advance booking can be made + `isNonRefundable` - True if product not refundable + `hasChildPrice` - Does product has child price + `minAdultAge` - The minimum age allowed for an adult + `maxAdultAge` - The maximum age allowed for an adult + `allowChildren` - Is a child allowed for this product + `minChildAge` - The minimum age allowed for a child + `maxChildAge` - The maximum age allowed for a child + `instantConfirmation` - if it's TRUE then booking this product should return new Booking status = `approved`, but if we're out of stock of e-tickets it can still return `waiting` + `voucherUse` - instruction on how to use the voucher (Using what? Go to what palce? To redeem with who?) + `voucherUseTranslated` - translated version of how to use voucher + `voucherRedemptionAddress` - Voucher redemption address IF client needs to redeem a voucher. + `voucherRedemptionAddressTranslated` - translated version of `voucherRedemptionAddress` + `recommendedMarkup` - Apply this markup if you want to match with BMG's website prices + `prices` - List of prices for Product Type for one month. The prices array consist of price for adults depending of number of adults and price for child. + `timeSlots` - Available timeslots for product, might be `null`. If the `ProductType` has timeslots, the `timeslotUUID` of the product is REQUIRED in `Check a Booking` and `Create a new booking` methods.+ `addons` - Add-ons for product+ `locations` - Information about product location+ `url` - URL of product + `staticUrl` - Static URL of product+ `guideLanguages` - Available languages speak by tour guide.+ `audioHeadsetLanguages` - Available languages for Audio Headset material.+ `writtenLanguages` - Available written languages for reading material.If product has been deleted from BeMyGuest database response will be: { "error": { "code": "GEN-GONE", "http_code": 410, "message": "Resource No Longer Available" } }### Promotional pricesExample of promotion data block: "promotion": { "type": "early_booking", "daysInAdvance": 30, "hoursInAdvance": null, "name": "Early Bird", "adult": { "2": 93.45 }, "child": 0, "discountPercent": 30, "cancellationPolicy": [] }- If product type has promotional prices for selected date only one promotion (with best price) will be visible in API.- there are 3 types of promotions (`type` parameter) : `early_booking`, `last_minute` and `discount`- `early_booking` will have value for `daysInAdvance` parameter provided (`hoursInAdvance` will be `NULL`)- `last_minute` will have value for `hoursInAdvance` provided (`daysInAdvance` will be `NULL`)- `discount` type will have both `daysInAdvance` and `hoursInAdvance` set to `NULL`
12
+ # @param [String] uuid Required parameter: UUID of product
13
+ # @param [String] currency Optional parameter: currency UUID, also currency code may be provided in exchange
14
+ # @param [String] date_end Optional parameter: product's prices end date, format YYYY-MM-DD
15
+ # @param [String] date_start Optional parameter: product's prices start date, format YYYY-MM-DD
16
+ # @param [String] language Optional parameter: language UUID, also language code may be provided
17
+ # @return GETProductResponse response from the API call
18
+ def get_product(uuid, currency = nil, date_end = nil, date_start = nil, language = nil)
19
+ # the base uri for api requests
20
+ query_builder = Configuration.base_uri.dup
21
+
22
+ # prepare query string for API call
23
+ query_builder << '/v1/products/{uuid}/'
24
+
25
+ # process optional query parameters
26
+ query_builder = APIHelper.append_url_with_template_parameters query_builder, {
27
+ 'uuid' => uuid
28
+ }
29
+
30
+ # process optional query parameters
31
+ query_builder = APIHelper.append_url_with_query_parameters query_builder, {
32
+ 'currency' => currency,
33
+ 'date_end' => date_end,
34
+ 'date_start' => date_start,
35
+ 'language' => language
36
+ }
37
+
38
+ # validate and preprocess url
39
+ query_url = APIHelper.clean_url query_builder
40
+
41
+ # prepare headers
42
+ headers = {
43
+ 'user-agent' => 'BeMyGuest.SDK.v1',
44
+ 'accept' => 'application/json',
45
+ 'X-Authorization' => Configuration.x_authorization
46
+ }
47
+
48
+ # invoke the API call request to fetch the response
49
+ response = Unirest.get query_url, headers: headers
50
+
51
+ # Error handling using HTTP status codes
52
+ if response.code == 410
53
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
54
+ elsif response.code == 400
55
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
56
+ elsif response.code == 401
57
+ raise APIException.new 'Unauthorized', 401, response.raw_body
58
+ elsif response.code == 403
59
+ raise APIException.new 'Forbidden', 403, response.raw_body
60
+ elsif response.code == 404
61
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
62
+ elsif response.code == 405
63
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
64
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
65
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
66
+ end
67
+
68
+ response.body
69
+ end
70
+
71
+ # ###ResponseA response object has the following attributes: + `uuid` - UUID of product+ `published` - true / false,+ `title` - Title of product. Always on English+ `titleTranslated` - Title of product on requested language+ `description` - Description of product. Always on English+ `descriptionTranslated` - Description of product on requested language+ `highlights` - Highlights of product. Always on English+ `highlightsTranslated` - Highlights of product on requested language+ `additionalInfo` - Additional information of product. Always on English+ `additionalInfoTranslated` - Additional information of product on requested language+ `priceIncludes` - What's included in product price+ `priceIncludesTranslated` - Translated version of `priceIncludes`+ `itinerary` - Activity itinerary - only applicable for Package type, will be `NULL` for others+ `itineraryTranslated` - translated version of itinerary+ `warnings` - Warnings of the activity (related to safety and insurance)+ `warningsTranslated` - translated version of warnings+ `safety` - activity safety information+ `safetyTranslated` - translated version of safety information+ `latitude` - Latitude+ `longitude` - Longitude+ `minPax` - Minimum number of pax+ `maxPax` - Maximum number of pax+ `basePrice` - Base price of product (for list only)+ `currency` - Currency+ `isFlatPaxPrice` - `true/false` (An indication to tell if the `Product` has the same price for each pax in all of its `productTypes` for the selected date. )+ `reviewCount` - Number of reviews+ `reviewAverageScore` - Average score+ `typeName` - Type of product+ `typeUuid` - Type UUID+ `businessHoursFrom` - supplier business hours `from`+ `businessHoursTo` - supplier business hours `to`+ `meetingTime` - meeting time+ `hotelPickup` - `true/false` + `meetingLocation` - instructions about meeting location with supplier+ `meetingLocationTranslated` - translated version of meeting location+ `photosUrl` - Base URL for images+ `photos` - Array of photos in different dimensions (Sizes: original, 75x50, 175x112, 680x325)+ `categories` - Array of categories+ `locations` - Information about product location+ `url` - URL of product If you requested only unpublished (`published` = `false`) products then the list will be simplified.Each element will consist only of these attributes: { "data": [ { "uuid":"b03ce312-742f-5256-bfe2-014daf1c8d01", "published":false, "title":"Everest BaseCamp Trek - 16 Days", "titleTranslated":null }, { "uuid":"d70fb77c-3e97-591e-b876-d638a643c41b", "published":false, "title":"Half day rock climbing, Ha Long Bay, Vietnam", "titleTranslated":null } [...] }If you requested only deleted (`deleted` = `false`) products then the list will be simplified.In this case `published` parameter will be ignored.This parameter exists to help partners to synchronize its cached products database.Each element will consist only of these attributes: { "data": [ { "uuid":"b03ce312-742f-5256-bfe2-014daf1c8d01", "deletedAt":"2015-06-01 14:28:37", "title":"Everest BaseCamp Trek - 16 Days", "titleTranslated":null }, { "uuid":"d70fb77c-3e97-591e-b876-d638a643c41b", "published":"deletedAt":"2015-06-01 14:28:37", "title":"Half day rock climbing, Ha Long Bay, Vietnam", "titleTranslated":null } [...] }###RequestA request can take these parameters:+ `type`: `b90bd912-3e92-52e6-8abb-c2722cf947db` (optional, string) - UUID of type of product+ `country`: `ebbfac98-5f89-5106-9c4e-9e5dfd485231` (optional, string) - UUID of country+ `city`: `f67e3919-036d-11e5-a2a9-d07e352b4840` (optional, string) - UUID of city - it will always overwrite (nullify) country parameter if provided+ `price_min`: 25.00 (optional, decimal) - minimal price in decimal format 000.00 - it's compared to base price+ `price_max`: 100.00 (optional, decimal) - max price in decimal format 000.00+ `category`: `5a6495b5-9a58-5257-93db-902ca3cf8b40` (optional, string) - UUID of litsing category+ `pax`: `2` (optional, integer) - number of guests+ `currency`: `79efbd4e-3648-5204-8f35-a0e51661a4c7` (optional, string) - currency UUID, also currency code may be provided in exchange+ `language`: `ZH-HANS` (optional, string) - language UUID, also language code may be provided+ `date_start`: `2015-06-25` (optional, string) - product start date, format YYYY-MM-DD+ `date_end`: `2015-06-30` (optional, string) - product end date, format YYYY-MM-DD+ `query`: `diving in Bali` (optional, string) - free phrase for text search for example &query=Bali+ `duration_days_min`: `0` (optional,integer) - product duration minimum days (default 0)+ `duration_days_max`: `0` (optional,integer) - product duration maximum days (default NULL)+ `latitude`: `1.313430` (optional, float) - search in distance radius: latitude value + `longitude`: `103.883768` (optional, float) - search in distance radius: longitude value+ `distance`: `10.5` (optional, float) - search in distance radius in km - to use this param you need to provide always 3 parameters: latitude, longitude and distance+ `sort`: `price` (optional, string) - sorting field, example: &sort=date,-price or &sort=price+ `page`: `5` (optional, integer) - page number for results+ `per_page`: `25` (optional, integer) - how many results per page - if not provided default value from user account will be used+ `published`: `true` (optional, string) - default is set to true, if set to false then a list of shortened unpublished products will be returned+ `deleted`: `false` (optional, string) - default is set to false, if set to true then a list of shortened deleted products will be returned
72
+ # @param [String] category Optional parameter: UUID of litsing category
73
+ # @param [String] city Optional parameter: UUID of city, it will always overwrite country parameter if provided
74
+ # @param [String] country Optional parameter: UUID of country
75
+ # @param [String] currency Optional parameter: currency UUID, also currency code may be provided in exchange
76
+ # @param [String] date_end Optional parameter: product end date, format YYYY-MM-DD
77
+ # @param [String] date_start Optional parameter: product start date, format YYYY-MM-DD
78
+ # @param [String] deleted Optional parameter: default is set to `false`
79
+ # @param [String] distance Optional parameter: Distance in km
80
+ # @param [Numeric] duration_days_max Optional parameter: product duration maximum days (default NULL)
81
+ # @param [Numeric] duration_days_min Optional parameter: product duration minimum days (default 0)
82
+ # @param [String] language Optional parameter: language UUID, also language code may be provided. It will overwrite the default language from user account
83
+ # @param [String] latitude Optional parameter: Latitude value
84
+ # @param [String] longitude Optional parameter: Longitute value
85
+ # @param [Double] page Optional parameter: page number for results
86
+ # @param [Double] pax Optional parameter: number of people
87
+ # @param [Double] per_page Optional parameter: how many results per page - if not provided default value from user account will be used
88
+ # @param [Numeric] price_max Optional parameter: max price in decimal format 000.00
89
+ # @param [Numeric] price_min Optional parameter: minimal price in decimal format 000.00 - it's compared to base price
90
+ # @param [String] published Optional parameter: default is always set to `true`
91
+ # @param [String] query Optional parameter: free phrase for text search for example &query=Bali
92
+ # @param [String] sort Optional parameter: sorting field, example: &sort=date,-price or &sort=price
93
+ # @param [String] type Optional parameter: UUID of type of product
94
+ # @return GETProductsResponse response from the API call
95
+ def get_products_list(category = nil, city = nil, country = nil, currency = nil, date_end = nil, date_start = nil, deleted = nil, distance = nil, duration_days_max = nil, duration_days_min = nil, language = nil, latitude = nil, longitude = nil, page = nil, pax = nil, per_page = nil, price_max = nil, price_min = nil, published = nil, query = nil, sort = nil, type = nil)
96
+ # the base uri for api requests
97
+ query_builder = Configuration.base_uri.dup
98
+
99
+ # prepare query string for API call
100
+ query_builder << '/v1/products'
101
+
102
+ # process optional query parameters
103
+ query_builder = APIHelper.append_url_with_query_parameters query_builder, {
104
+ 'category' => category,
105
+ 'city' => city,
106
+ 'country' => country,
107
+ 'currency' => currency,
108
+ 'date_end' => date_end,
109
+ 'date_start' => date_start,
110
+ 'deleted' => deleted,
111
+ 'distance' => distance,
112
+ 'duration_days_max' => duration_days_max,
113
+ 'duration_days_min' => duration_days_min,
114
+ 'language' => language,
115
+ 'latitude' => latitude,
116
+ 'longitude' => longitude,
117
+ 'page' => page,
118
+ 'pax' => pax,
119
+ 'per_page' => per_page,
120
+ 'price_max' => price_max,
121
+ 'price_min' => price_min,
122
+ 'published' => published,
123
+ 'query' => query,
124
+ 'sort' => sort,
125
+ 'type' => type
126
+ }
127
+
128
+ # validate and preprocess url
129
+ query_url = APIHelper.clean_url query_builder
130
+
131
+ # prepare headers
132
+ headers = {
133
+ 'user-agent' => 'BeMyGuest.SDK.v1',
134
+ 'accept' => 'application/json',
135
+ 'X-Authorization' => Configuration.x_authorization
136
+ }
137
+
138
+ # invoke the API call request to fetch the response
139
+ response = Unirest.get query_url, headers: headers
140
+
141
+ # Error handling using HTTP status codes
142
+ if response.code == 400
143
+ raise APIException.new 'Wrong Arguments', 400, response.raw_body
144
+ elsif response.code == 401
145
+ raise APIException.new 'Unauthorized', 401, response.raw_body
146
+ elsif response.code == 403
147
+ raise APIException.new 'Forbidden', 403, response.raw_body
148
+ elsif response.code == 404
149
+ raise APIException.new 'Resource Not Found', 404, response.raw_body
150
+ elsif response.code == 405
151
+ raise APIException.new 'Method Not Allowed', 405, response.raw_body
152
+ elsif response.code == 410
153
+ raise APIException.new 'Resource No Longer Available', 410, response.raw_body
154
+ elsif !response.code.between?(200, 206) # [200,206] = HTTP OK
155
+ raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body
156
+ end
157
+
158
+ response.body
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,25 @@
1
+ # Extracted from Remote API gem (https://github.com/cstrahan/rapi).
2
+
3
+ module BeMyGuestApiv1
4
+ class BaseStringEnum
5
+
6
+ private
7
+ def self.enum_attr(name, val)
8
+ name = name.to_s
9
+
10
+ define_method(name + '?') do
11
+ @attrs == val
12
+ end
13
+ end
14
+
15
+ public
16
+ def initialize(attrs = '')
17
+ @attrs = attrs
18
+ end
19
+
20
+ def to_s
21
+ @attrs
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ require 'be_my_guest_apiv_1/models/base_string_enum'
4
+
5
+ module BeMyGuestApiv1
6
+ class BookingStatusEnum < BaseStringEnum
7
+
8
+ # Confirms given booking
9
+ enum_attr :CONFIRM, 'confirm'
10
+
11
+ # Cancels given booking
12
+ enum_attr :CANCEL, 'cancel'
13
+
14
+ # If confirmationEmailSentAt value is not null then copy of the confirmation email sent to partner will be sent again and the timestamp value of this field will be updated
15
+ enum_attr :RESEND, 'resend'
16
+
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ require 'be_my_guest_apiv_1/models/base_string_enum'
4
+
5
+ module BeMyGuestApiv1
6
+ class BookingStatusesEnum < BaseStringEnum
7
+
8
+ # TODO: Write general description for this element
9
+ enum_attr :RESERVED, 'reserved'
10
+
11
+ # TODO: Write general description for this element
12
+ enum_attr :WAITING, 'waiting'
13
+
14
+ # TODO: Write general description for this element
15
+ enum_attr :CANCELLED, 'cancelled'
16
+
17
+ # TODO: Write general description for this element
18
+ enum_attr :APPROVED, 'approved'
19
+
20
+ # TODO: Write general description for this element
21
+ enum_attr :EXPIRED, 'expired'
22
+
23
+ # TODO: Write general description for this element
24
+ enum_attr :REJECTED, 'rejected'
25
+
26
+ # TODO: Write general description for this element
27
+ enum_attr :RELEASED, 'released'
28
+
29
+ # TODO: Write general description for this element
30
+ enum_attr :REFUNDED, 'refunded'
31
+
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class CheckABookingRequest
5
+ # TODO: Write general description for this method
6
+ # @return [String]
7
+ attr_accessor :product_type_uuid
8
+
9
+ # TODO: Write general description for this method
10
+ # @return [Numeric]
11
+ attr_accessor :pax
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [Numeric]
15
+ attr_accessor :children
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [String]
19
+ attr_accessor :time_slot_uuid
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [Array<mixed>]
23
+ attr_accessor :addons
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [String]
27
+ attr_accessor :arrival_date
28
+
29
+ # TODO: Write general description for this method
30
+ # @return [Boolean]
31
+ attr_accessor :use_promotion
32
+
33
+ def method_missing(method_name)
34
+ puts "there's no method called '#{method_name}'"
35
+ end
36
+
37
+ # Creates JSON of the curent object
38
+ def to_json
39
+ hash = key_map
40
+ hash.to_json
41
+ end
42
+
43
+ # Defines the key map for json serialization
44
+ def key_map
45
+ hash = {}
46
+ hash['productTypeUuid'] = product_type_uuid
47
+ hash['pax'] = pax
48
+ hash['children'] = children
49
+ hash['timeSlotUuid'] = time_slot_uuid
50
+ hash['addons'] = addons
51
+ hash['arrivalDate'] = arrival_date
52
+ hash['usePromotion'] = use_promotion
53
+ hash
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,91 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class CreateABookingRequest
5
+ # One of Mr.|Ms.|Mrs.
6
+ # @return [String]
7
+ attr_accessor :salutation
8
+
9
+ # Guest's first name
10
+ # @return [String]
11
+ attr_accessor :first_name
12
+
13
+ # Guest's last name
14
+ # @return [String]
15
+ attr_accessor :last_name
16
+
17
+ # Guest's email address
18
+ # @return [String]
19
+ attr_accessor :email
20
+
21
+ # Guest's phone number
22
+ # @return [String]
23
+ attr_accessor :phone
24
+
25
+ # Message to the host
26
+ # @return [String]
27
+ attr_accessor :message
28
+
29
+ # UUID of the ProductType
30
+ # @return [String]
31
+ attr_accessor :product_type_uuid
32
+
33
+ # Number of adults
34
+ # @return [Numeric]
35
+ attr_accessor :pax
36
+
37
+ # Number of children
38
+ # @return [Numeric]
39
+ attr_accessor :children
40
+
41
+ # Selected timeslot. If the product has timeslots, the "timeslotUUID" of the product is REQUIRED in "Check a Booking" and "Create a new booking" methods. Otherwise, it can be excluded
42
+ # @return [String]
43
+ attr_accessor :time_slot_uuid
44
+
45
+ # Add-ons for product (array of uuid/quantity values)
46
+ # @return [Array<mixed>]
47
+ attr_accessor :addons
48
+
49
+ # Arrival date in YYYY-MM-DD format
50
+ # @return [String]
51
+ attr_accessor :arrival_date
52
+
53
+ # Maximum 36 characters partner reference code or number
54
+ # @return [String]
55
+ attr_accessor :partner_reference
56
+
57
+ # f API should check price against "promotion" and not "regular" , default is set to "false"
58
+ # @return [Boolean]
59
+ attr_accessor :use_promotion
60
+
61
+ def method_missing(method_name)
62
+ puts "there's no method called '#{method_name}'"
63
+ end
64
+
65
+ # Creates JSON of the curent object
66
+ def to_json
67
+ hash = key_map
68
+ hash.to_json
69
+ end
70
+
71
+ # Defines the key map for json serialization
72
+ def key_map
73
+ hash = {}
74
+ hash['salutation'] = salutation
75
+ hash['firstName'] = first_name
76
+ hash['lastName'] = last_name
77
+ hash['email'] = email
78
+ hash['phone'] = phone
79
+ hash['message'] = message
80
+ hash['productTypeUuid'] = product_type_uuid
81
+ hash['pax'] = pax
82
+ hash['children'] = children
83
+ hash['timeSlotUuid'] = time_slot_uuid
84
+ hash['addons'] = addons
85
+ hash['arrivalDate'] = arrival_date
86
+ hash['partnerReference'] = partner_reference
87
+ hash['usePromotion'] = use_promotion
88
+ hash
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,31 @@
1
+ # This file was automatically generated for BeMyGuest by APIMATIC v2.0 on 05/03/2016
2
+
3
+ module BeMyGuestApiv1
4
+ class UpdateBookingRequest
5
+ # TODO: Write general description for this method
6
+ # @return [String]
7
+ attr_accessor :uuid
8
+
9
+ # TODO: Write general description for this method
10
+ # @return [BookingStatusEnum]
11
+ attr_accessor :status
12
+
13
+ def method_missing(method_name)
14
+ puts "there's no method called '#{method_name}'"
15
+ end
16
+
17
+ # Creates JSON of the curent object
18
+ def to_json
19
+ hash = key_map
20
+ hash.to_json
21
+ end
22
+
23
+ # Defines the key map for json serialization
24
+ def key_map
25
+ hash = {}
26
+ hash['uuid'] = uuid
27
+ hash['status'] = status
28
+ hash
29
+ end
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bemyguest_sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - APIMATIC
9
+ - Zeeshan Ejaz Bhatti
10
+ - BeMyGuest
11
+ - Jarek Tkaczyk @ BeMyGuest
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2016-05-05 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: unirest
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 1.1.2
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.2
33
+ description: SDK for the BeMyGuest REST API. This API SDK was automatically generated
34
+ by APIMATIC v2.0
35
+ email: tech@bemyguest.com.sg
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - lib/be_my_guest_apiv_1.rb
41
+ - lib/be_my_guest_apiv_1/configuration.rb
42
+ - lib/be_my_guest_apiv_1/api_exception.rb
43
+ - lib/be_my_guest_apiv_1/models/create_a_booking_request.rb
44
+ - lib/be_my_guest_apiv_1/models/booking_status_enum.rb
45
+ - lib/be_my_guest_apiv_1/models/update_booking_request.rb
46
+ - lib/be_my_guest_apiv_1/models/booking_statuses_enum.rb
47
+ - lib/be_my_guest_apiv_1/models/base_string_enum.rb
48
+ - lib/be_my_guest_apiv_1/models/check_a_booking_request.rb
49
+ - lib/be_my_guest_apiv_1/controllers/bookings_controller.rb
50
+ - lib/be_my_guest_apiv_1/controllers/products_controller.rb
51
+ - lib/be_my_guest_apiv_1/controllers/config_controller.rb
52
+ - lib/be_my_guest_apiv_1/api_helper.rb
53
+ - lib/be_my_guest_apiv_1/be_my_guest_apiv_1_client.rb
54
+ - README.md
55
+ - LICENSE
56
+ homepage: https://docs.bemyguest.apiary.io
57
+ licenses:
58
+ - MIT
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.23
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: bemyguest_api_sdk
81
+ test_files: []