bookingsync-api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9feafbe1659c58b2d4914234364c5f19e7e56a2
4
- data.tar.gz: b10ca8cf51d587cdca7704e36680e92a36ba7c1c
3
+ metadata.gz: 482e5a2b0789e895be5b708da4e0695d9f0a260f
4
+ data.tar.gz: 9243586b0e24bbab147f20ecbce0b6da009de350
5
5
  SHA512:
6
- metadata.gz: feefb5721a6bbf3874302873de4e7efa2f63ab31880674c61122fad6c4dceca87e53ed42f1545595a936042b0ef72dc2a5bd8302799d132fffda0a697713e422
7
- data.tar.gz: aa7419b2ad612b546f71fc36e1b0098284a0c1dc503c2d4a78749e7cdef96bfb8180c31bfcbb0ace7b1168661089fdb3074cdd0d0134765465d7b99a3d69206f
6
+ metadata.gz: 366e4825396ef6b9cfcb2596c4ac9fdab053c8b8ce0a82ecfc7c16817724b3995df63eddc5e6e386ce077188b2286f3828fbd5a23875f5f5c82035376a1f4312
7
+ data.tar.gz: ae0492b2ab4c56881ba3c225357cd72fd24d981ca94f2e6d602f1236d8914a1e4c0a65e61cfba93efe9312565ac7ebf0eb15d6be2059a4d28e4e3c4e4e72f939
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group 'test' do
9
9
  gem 'guard'
10
10
  gem 'guard-rspec'
11
11
  gem 'yard'
12
+ gem 'guard-yard'
12
13
  end
13
14
 
14
15
  gemspec
data/Guardfile CHANGED
@@ -4,3 +4,7 @@ guard :rspec do
4
4
  watch(%r{^lib/bookingsync/api/(.+)\.rb$}) { |m| "spec/bookingsync/api/#{m[1]}_spec.rb" }
5
5
  watch('spec/spec_helper.rb') { "spec" }
6
6
  end
7
+
8
+ guard 'yard' do
9
+ watch(%r{lib/.+\.rb})
10
+ end
@@ -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 options [Hash] A customizable set of options.
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, options = {})
48
- request_options = {}
49
- if options.has_key?(:fields)
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, request_options)
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
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  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.3
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-12 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday