bookingsync-api 0.0.3 → 0.0.4
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 +4 -4
- data/Gemfile +1 -0
- data/Guardfile +4 -0
- data/lib/bookingsync/api/client.rb +5 -8
- data/lib/bookingsync/api/client/bookings.rb +11 -1
- data/lib/bookingsync/api/version.rb +1 -1
- data/spec/bookingsync/api/client_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482e5a2b0789e895be5b708da4e0695d9f0a260f
|
4
|
+
data.tar.gz: 9243586b0e24bbab147f20ecbce0b6da009de350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366e4825396ef6b9cfcb2596c4ac9fdab053c8b8ce0a82ecfc7c16817724b3995df63eddc5e6e386ce077188b2286f3828fbd5a23875f5f5c82035376a1f4312
|
7
|
+
data.tar.gz: ae0492b2ab4c56881ba3c225357cd72fd24d981ca94f2e6d602f1236d8914a1e4c0a65e61cfba93efe9312565ac7ebf0eb15d6be2059a4d28e4e3c4e4e72f939
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -41,17 +41,14 @@ module BookingSync::API
|
|
41
41
|
#
|
42
42
|
# @param method [Symbol] HTTP verb to use.
|
43
43
|
# @param path [String] The path, relative to {#api_endpoint}.
|
44
|
-
# @param
|
45
|
-
# @option options [Array] fields: List of fields to be fetched.
|
44
|
+
# @param query [Hash] A customizable set of query options.
|
46
45
|
# @return [Array<Sawyer::Resource>] Array of resources.
|
47
|
-
def request(method, path,
|
48
|
-
|
49
|
-
|
50
|
-
fields = Array(options[:fields]).join(",")
|
51
|
-
request_options[:query] = {fields: fields}
|
46
|
+
def request(method, path, query = {})
|
47
|
+
[:fields, :status].each do |key|
|
48
|
+
query[key] = Array(query[key]).join(",") if query.has_key?(key)
|
52
49
|
end
|
53
50
|
|
54
|
-
response = agent.call(method, path, nil,
|
51
|
+
response = agent.call(method, path, nil, {query: query})
|
55
52
|
case response.status
|
56
53
|
# fetch objects from outer hash
|
57
54
|
# {rentals => [{rental}, {rental}]}
|
@@ -5,9 +5,19 @@ module BookingSync::API
|
|
5
5
|
#
|
6
6
|
# Return public future bookings for the account user
|
7
7
|
# is authenticated with.
|
8
|
-
# @param options [Hash] A customizable set of options.
|
8
|
+
# @param options [Hash] A customizable set of query options.
|
9
9
|
# @option options [Array] fields: List of fields to be fetched.
|
10
|
+
# @option options [Time] from: Select bookings ending after given date.
|
11
|
+
# @option options [Time] until: Select bookings starting before given date.
|
12
|
+
# @option options [Integer] months: Select bookings starting before
|
13
|
+
# :from + months, if :from is blank, current time is taken.
|
14
|
+
# @option options [Boolean] include_canceled: If true canceled bookings
|
15
|
+
# are shown, otherwise they are hidden.
|
16
|
+
# @option options [Array] status: Array of booking states.
|
17
|
+
# If specyfied bookings with given states are shown.
|
10
18
|
# @return [Array<Sawyer::Resource>] Array of bookings.
|
19
|
+
# @example
|
20
|
+
# @api.bookings(months: 12, states: [:booked, :unavailable], include_canceled: true)
|
11
21
|
def bookings(options = {})
|
12
22
|
get :bookings, options
|
13
23
|
end
|
@@ -66,6 +66,14 @@ describe BookingSync::API::Client do
|
|
66
66
|
assert_requested :get, bs_url("resource?fields=name,description")
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
context "user passes additional query options" do
|
71
|
+
it "constructs url with query options" do
|
72
|
+
stub_get("resource?months=12&status=booked,unavailable")
|
73
|
+
client.get("resource", status: [:booked, :unavailable], months: '12')
|
74
|
+
assert_requested :get, bs_url("resource?months=12&status=booked,unavailable")
|
75
|
+
end
|
76
|
+
end
|
69
77
|
end
|
70
78
|
|
71
79
|
describe "#api_endpoint" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookingsync-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Grosjean
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|