bookingsync-api 0.0.4 → 0.0.5

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.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -1
  3. data/lib/bookingsync/api.rb +1 -0
  4. data/lib/bookingsync/api/client.rb +80 -10
  5. data/lib/bookingsync/api/client/bookings.rb +42 -2
  6. data/lib/bookingsync/api/client/inquiries.rb +23 -0
  7. data/lib/bookingsync/api/client/rentals.rb +3 -2
  8. data/lib/bookingsync/api/error.rb +1 -0
  9. data/lib/bookingsync/api/version.rb +1 -1
  10. data/lib/bookingsync/ext/resource.rb +9 -0
  11. data/spec/bookingsync/api/client/bookings_spec.rb +78 -0
  12. data/spec/bookingsync/api/client/inquiries_spec.rb +37 -0
  13. data/spec/bookingsync/api/client_spec.rb +65 -3
  14. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml +190 -0
  15. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_auto_paginate_true/returns_all_bookings_joined_from_many_requests.yml +190 -0
  16. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_per_page_setting/returns_limited_number_of_bookings.yml +65 -0
  17. data/spec/cassettes/BookingSync_API_Client_Bookings/_cancel_booking/cancels_given_booking.yml +57 -0
  18. data/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml +63 -0
  19. data/spec/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml +57 -0
  20. data/spec/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml +64 -0
  21. data/spec/cassettes/BookingSync_API_Client_Inquiries/_inquiries/returns_inquiries.yml +64 -0
  22. data/spec/cassettes/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking_yml.yml +62 -0
  23. data/spec/spec_helper.rb +24 -0
  24. metadata +24 -2
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bookingsync.com/api/v3/bookings
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"bookings\":[{\"start_at\":\"2014-01-03\",\"end_at\":\"2014-01-04\",\"rental_id\":20,\"booked\":true}]}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ X-Ratelimit-Limit:
26
+ - '1000'
27
+ X-Ratelimit-Reset:
28
+ - '1395313200'
29
+ X-Ratelimit-Remaining:
30
+ - '997'
31
+ Location:
32
+ - https://www.bookingsync.com/api/v3/bookings/72.json
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Access-Control-Request-Method:
36
+ - "*"
37
+ Content-Type:
38
+ - application/vnd.api+json; charset=utf-8
39
+ X-Ua-Compatible:
40
+ - IE=Edge
41
+ Etag:
42
+ - "\"de807f21b0a4b759fc2274c989f281dc\""
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ P3p:
46
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
47
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
48
+ Set-Cookie:
49
+ - _BookingSync_session=65637dcc7218f300e75044ecf77e7eb1; path=/; secure; HttpOnly
50
+ X-Request-Id:
51
+ - 29dfa15561c7c65997760b20c0be6ebe
52
+ X-Runtime:
53
+ - '0.053762'
54
+ Date:
55
+ - Thu, 20 Mar 2014 10:25:01 GMT
56
+ Connection:
57
+ - close
58
+ body:
59
+ encoding: UTF-8
60
+ string: "{\"bookings\":[{\"id\":72,\"account_id\":1,\"rental_id\":20,\"start_at\":\"2014-01-03T00:00:00Z\",\"end_at\":\"2014-01-04T00:00:00Z\"}]}"
61
+ http_version:
62
+ recorded_at: Thu, 20 Mar 2014 10:25:01 GMT
63
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://www.bookingsync.com/api/v3/bookings/50
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"bookings\":[{\"adults\":1}]}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 204
23
+ message: No Content
24
+ headers:
25
+ X-Ratelimit-Limit:
26
+ - '1000'
27
+ X-Ratelimit-Reset:
28
+ - '1395352800'
29
+ X-Ratelimit-Remaining:
30
+ - '994'
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Access-Control-Request-Method:
34
+ - "*"
35
+ X-Ua-Compatible:
36
+ - IE=Edge
37
+ Cache-Control:
38
+ - no-cache
39
+ P3p:
40
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
41
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
42
+ Set-Cookie:
43
+ - _BookingSync_session=88df7b72b145935f2f668eaeab10d73f; path=/; secure; HttpOnly
44
+ X-Request-Id:
45
+ - 9cffd4e20d9a9a791ea3b731982ee735
46
+ X-Runtime:
47
+ - '1.418879'
48
+ Date:
49
+ - Thu, 20 Mar 2014 21:45:42 GMT
50
+ Connection:
51
+ - close
52
+ body:
53
+ encoding: UTF-8
54
+ string: ''
55
+ http_version:
56
+ recorded_at: Thu, 20 Mar 2014 21:45:42 GMT
57
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bookingsync.com/api/v3/inquiries
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"inquiries\":[{\"rental_id\":7,\"start_at\":\"2014-03-25 16:49:59
9
+ +0100\",\"end_at\":\"2014-03-26 16:49:59 +0100\",\"firstname\":\"John\",\"lastname\":\"Smith\",\"email\":\"john@example.com\"}]}"
10
+ headers:
11
+ User-Agent:
12
+ - Faraday v0.9.0
13
+ Accept:
14
+ - application/vnd.api+json
15
+ Content-Type:
16
+ - application/vnd.api+json
17
+ Authorization:
18
+ - Bearer <<ACCESS_TOKEN>>
19
+ Accept-Encoding:
20
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
21
+ response:
22
+ status:
23
+ code: 201
24
+ message: Created
25
+ headers:
26
+ X-Ratelimit-Limit:
27
+ - '1000'
28
+ X-Ratelimit-Reset:
29
+ - '1395763200'
30
+ X-Ratelimit-Remaining:
31
+ - '995'
32
+ Location:
33
+ - https://www.bookingsync.com/api/v3/inquiries/2.json
34
+ Access-Control-Allow-Origin:
35
+ - "*"
36
+ Access-Control-Request-Method:
37
+ - "*"
38
+ Content-Type:
39
+ - application/vnd.api+json; charset=utf-8
40
+ X-Ua-Compatible:
41
+ - IE=Edge
42
+ Etag:
43
+ - "\"c981057d155d5d184ea98ee77b860c87\""
44
+ Cache-Control:
45
+ - max-age=0, private, must-revalidate
46
+ P3p:
47
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
48
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
49
+ Set-Cookie:
50
+ - _BookingSync_session=e12728bb7449d8680601f2fce8bd34ef; path=/; secure; HttpOnly
51
+ X-Request-Id:
52
+ - e5ef73fe38071d0813a90b3d84008b6d
53
+ X-Runtime:
54
+ - '1.391176'
55
+ Date:
56
+ - Tue, 25 Mar 2014 15:50:13 GMT
57
+ Connection:
58
+ - close
59
+ body:
60
+ encoding: UTF-8
61
+ string: "{\"inquiries\":[{\"id\":2,\"firstname\":\"John\",\"lastname\":\"Smith\",\"email\":\"john@example.com\",\"country_code\":null,\"phone\":null,\"start_at\":\"2014-03-25T16:00:00Z\",\"end_at\":\"2014-03-26T10:00:00Z\",\"adults\":null,\"children\":null,\"rental_id\":7,\"message\":null,\"created_at\":\"2014-03-25T15:50:12Z\",\"updated_at\":\"2014-03-25T15:50:12Z\"}]}"
62
+ http_version:
63
+ recorded_at: Tue, 25 Mar 2014 15:50:13 GMT
64
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.bookingsync.com/api/v3/inquiries
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Ratelimit-Limit:
26
+ - '1000'
27
+ X-Ratelimit-Reset:
28
+ - '1395763200'
29
+ X-Ratelimit-Remaining:
30
+ - '996'
31
+ Link:
32
+ - "<https://www.bookingsync.com/api/v3/inquiries.json?page=1>; rel=\"first\", <https://www.bookingsync.com/api/v3/inquiries.json?page=1>;
33
+ rel=\"last\""
34
+ X-Total-Pages:
35
+ - '1'
36
+ Access-Control-Allow-Origin:
37
+ - "*"
38
+ Access-Control-Request-Method:
39
+ - "*"
40
+ Content-Type:
41
+ - application/vnd.api+json; charset=utf-8
42
+ X-Ua-Compatible:
43
+ - IE=Edge
44
+ Etag:
45
+ - "\"5ce3f361e48a5948646c6c51dd86b319\""
46
+ Cache-Control:
47
+ - max-age=0, private, must-revalidate
48
+ P3p:
49
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
50
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
51
+ X-Request-Id:
52
+ - 966f6c2d18bb20ba61f88d00b869ac42
53
+ X-Runtime:
54
+ - '0.173138'
55
+ Date:
56
+ - Tue, 25 Mar 2014 15:22:25 GMT
57
+ Connection:
58
+ - close
59
+ body:
60
+ encoding: UTF-8
61
+ string: "{\"inquiries\":[{\"id\":1,\"firstname\":\"John\",\"lastname\":\"Smith\",\"email\":\"john@example.com\",\"country_code\":null,\"phone\":null,\"start_at\":\"2014-03-27T16:00:00Z\",\"end_at\":\"2014-03-28T10:00:00Z\",\"adults\":null,\"children\":null,\"rental_id\":2,\"message\":null,\"created_at\":\"2014-03-25T15:10:28Z\",\"updated_at\":\"2014-03-25T15:10:28Z\"}]}"
62
+ http_version:
63
+ recorded_at: Tue, 25 Mar 2014 15:22:25 GMT
64
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bookingsync.com/api/v3/bookings
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{\"bookings\":[{\"start_at\":\"2014-01-03\",\"end_at\":\"2014-01-04\",\"rental_id\":20,\"booked\":true}]}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 401
23
+ message: Unauthorized
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Thu, 20 Mar 2014 16:45:00 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 401 Unauthorized
37
+ Cache-Control:
38
+ - no-store
39
+ Pragma:
40
+ - no-cache
41
+ Www-Authenticate:
42
+ - Bearer realm="Doorkeeper", error="invalid_token", error_description="The access
43
+ token is invalid"
44
+ X-Ua-Compatible:
45
+ - IE=Edge,chrome=1
46
+ P3p:
47
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
48
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
49
+ Set-Cookie:
50
+ - _BookingSync_session=94d440c5870c0eaf984b8151c68d9a22; path=/; secure; HttpOnly
51
+ X-Request-Id:
52
+ - 16639592b69d65a334efe38db30ac9df
53
+ X-Runtime:
54
+ - '0.049714'
55
+ X-Rack-Cache:
56
+ - invalidate, pass
57
+ body:
58
+ encoding: UTF-8
59
+ string: "{\"error\":\"Not authorized\"}"
60
+ http_version:
61
+ recorded_at: Thu, 20 Mar 2014 16:45:00 GMT
62
+ recorded_with: VCR 2.8.0
data/spec/spec_helper.rb CHANGED
@@ -38,3 +38,27 @@ def stub_get(path, options = {})
38
38
  }.merge(options)
39
39
  stub_request(:get, bs_url(path)).to_return(response)
40
40
  end
41
+
42
+ def stub_post(path, options = {})
43
+ response = {
44
+ body: {}.to_json,
45
+ headers: {"Content-Type" => "application/vnd.api+json"}
46
+ }.merge(options)
47
+ stub_request(:post, bs_url(path)).to_return(response)
48
+ end
49
+
50
+ def stub_put(path, options = {})
51
+ response = {
52
+ body: {}.to_json,
53
+ headers: {"Content-Type" => "application/vnd.api+json"}
54
+ }.merge(options)
55
+ stub_request(:put, bs_url(path)).to_return(response)
56
+ end
57
+
58
+ def stub_delete(path, options = {})
59
+ response = {
60
+ body: {}.to_json,
61
+ headers: {"Content-Type" => "application/vnd.api+json"}
62
+ }.merge(options)
63
+ stub_request(:delete, bs_url(path)).to_return(response)
64
+ end
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
4
+ version: 0.0.5
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-20 00:00:00.000000000 Z
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -86,17 +86,29 @@ files:
86
86
  - lib/bookingsync/api.rb
87
87
  - lib/bookingsync/api/client.rb
88
88
  - lib/bookingsync/api/client/bookings.rb
89
+ - lib/bookingsync/api/client/inquiries.rb
89
90
  - lib/bookingsync/api/client/rentals.rb
90
91
  - lib/bookingsync/api/error.rb
91
92
  - lib/bookingsync/api/middleware/authentication.rb
92
93
  - lib/bookingsync/api/version.rb
94
+ - lib/bookingsync/ext/resource.rb
93
95
  - spec/bookingsync/api/client/bookings_spec.rb
96
+ - spec/bookingsync/api/client/inquiries_spec.rb
94
97
  - spec/bookingsync/api/client/rentals_spec.rb
95
98
  - spec/bookingsync/api/client_spec.rb
96
99
  - spec/bookingsync/api_spec.rb
100
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml
101
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_auto_paginate_true/returns_all_bookings_joined_from_many_requests.yml
102
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_per_page_setting/returns_limited_number_of_bookings.yml
97
103
  - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/returns_bookings.yml
104
+ - spec/cassettes/BookingSync_API_Client_Bookings/_cancel_booking/cancels_given_booking.yml
105
+ - spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml
106
+ - spec/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml
107
+ - spec/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml
108
+ - spec/cassettes/BookingSync_API_Client_Inquiries/_inquiries/returns_inquiries.yml
98
109
  - spec/cassettes/BookingSync_API_Client_Rentals/_rentals/returns_rentals.yml
99
110
  - spec/cassettes/BookingSync_API_Client_Rentals/_rentals/with_specified_fields_in_options/returns_rentals_with_filtered_fields.yml
111
+ - spec/cassettes/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking_yml.yml
100
112
  - spec/spec_helper.rb
101
113
  homepage: https://github.com/BookingSync/bookingsync-api
102
114
  licenses:
@@ -124,11 +136,21 @@ specification_version: 4
124
136
  summary: Ruby interface for accessing https://www.bookingsync.com
125
137
  test_files:
126
138
  - spec/bookingsync/api/client/bookings_spec.rb
139
+ - spec/bookingsync/api/client/inquiries_spec.rb
127
140
  - spec/bookingsync/api/client/rentals_spec.rb
128
141
  - spec/bookingsync/api/client_spec.rb
129
142
  - spec/bookingsync/api_spec.rb
143
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml
144
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_auto_paginate_true/returns_all_bookings_joined_from_many_requests.yml
145
+ - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_per_page_setting/returns_limited_number_of_bookings.yml
130
146
  - spec/cassettes/BookingSync_API_Client_Bookings/_bookings/returns_bookings.yml
147
+ - spec/cassettes/BookingSync_API_Client_Bookings/_cancel_booking/cancels_given_booking.yml
148
+ - spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml
149
+ - spec/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml
150
+ - spec/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml
151
+ - spec/cassettes/BookingSync_API_Client_Inquiries/_inquiries/returns_inquiries.yml
131
152
  - spec/cassettes/BookingSync_API_Client_Rentals/_rentals/returns_rentals.yml
132
153
  - spec/cassettes/BookingSync_API_Client_Rentals/_rentals/with_specified_fields_in_options/returns_rentals_with_filtered_fields.yml
154
+ - spec/cassettes/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking_yml.yml
133
155
  - spec/spec_helper.rb
134
156
  has_rdoc: