mr_speedy_ruby 1.0.0.pre.alpha.2 → 1.0.0.pre.alpha.3

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
  SHA256:
3
- metadata.gz: 2156a454d95152c80a1ad9e229193bde625d4f8f75af06f074cbf7425aa60983
4
- data.tar.gz: 8c5915a58da4cbb598a99fda9d04b32e3d1900343b540bc6e90b40eafbc2482d
3
+ metadata.gz: 165397e3f490933a9629fab7f1ccdbbc46f8dfb930c377c71435a8d719de64e1
4
+ data.tar.gz: fe00bea9f37148d44c08fcb6ec69b0c8b53db1e556afa828b89a542feca152d8
5
5
  SHA512:
6
- metadata.gz: c72899df3891543bb8c36c025f67674b64a52bcdaeb1e65e4ceef354fb43702fc5918348746a626e6dfd98612693a092317f3c458f376729de5d7c5c2c2479e7
7
- data.tar.gz: '0912f29cdacf1375a72bb48562d651b98adeaa1efd891ab535a2be8cfa0b69be055faf335f039d7b70891e637cfb78c52b056d2099673c485b3bc73bdff44ace'
6
+ metadata.gz: 3c0e07138c3bfc72d5ed0692dd896c754e9e5c42455b345b9b6c546a180c32ed646962ae583d86c20109b3f758682efeda2436c5758dad7021d83a437cfdb90b
7
+ data.tar.gz: 9013f4c7096f909db62dab0e812d682dc8a10f3bca1026cd50fcfdb912df815d0e60dc1b7824eb1e7a251aeb924daa4d6b1e857698149b2125e309c8f9f7b197
data/.travis.yml CHANGED
@@ -5,3 +5,5 @@ cache: bundler
5
5
  rvm:
6
6
  - 2.5.0
7
7
  before_install: gem install bundler -v 2.0.2
8
+ script:
9
+ - bundle exec rake test
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mr_speedy_ruby (1.0.0.pre.alpha.2)
4
+ mr_speedy_ruby (1.0.0.pre.alpha.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -81,6 +81,8 @@ to make a request on mr.speedy sandbox server.
81
81
 
82
82
  By default we set `MOTORBIKE` as default vehicle unless you pass `vehicle_type_id` as option for `opts`.
83
83
 
84
+ ## Orders
85
+
84
86
  ### Placing an Order
85
87
  Send request to mr.speedy api to create order.
86
88
 
@@ -118,6 +120,26 @@ parameter to true to test our implementation against sandbox server.
118
120
 
119
121
  By default we set `MOTORBIKE` as default vehicle unless you pass `vehicle_type_id` as option for `opts`.
120
122
 
123
+ ### Fetch Orders
124
+
125
+ Fetch Orders by initializing client and calling `MrSpeedyRuby::Client#orders`
126
+ method
127
+
128
+ ```ruby
129
+ client = MrSpeedyRuby::Client.new(token: "mr-speedy-token")
130
+ client.orders(sandbox: true)
131
+ ```
132
+
133
+ You can also control how orders will be fetch by supplying additional
134
+ [arguments](https://apitest.mrspeedy.ph/business-api/doc#orders) to your query
135
+ via payload argument.
136
+
137
+ ```ruby
138
+ client = MrSpeedyRuby::Client.new(token: "mr-speedy-token")
139
+ # Fetch Completed Orders
140
+ client.orders(sandbox: true, payload: { status: "completed" })
141
+ ```
142
+
121
143
  ## Development
122
144
 
123
145
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -131,7 +153,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
131
153
  - [x] Create Order
132
154
  - [ ] Update Order
133
155
  - [ ] Cancel Order
134
- - [ ] Order List
156
+ - [x] Order List
135
157
  - [ ] Courier Info and Location Tracker
136
158
  - [ ] Create Draft Deliveries
137
159
  - [ ] Update Draft Deliveries
@@ -0,0 +1,64 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://robotapitest.mrspeedy.ph/api/business/1.1/orders
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - robotapitest.mrspeedy.ph
18
+ X-Dv-Auth-Token:
19
+ - 70B4ABCA8A35AC50E1585E27F217DF160F740D46
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Wed, 13 May 2020 14:48:08 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Vary:
36
+ - Accept-Encoding
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Xss-Protection:
42
+ - 1; mode=block;
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: '{"is_successful":true,"orders":[{"order_id":77802,"order_name":"77802","vehicle_type_id":8,"created_datetime":"2020-05-12T21:22:21+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203156,"client_order_id":null,"address":"Zurich
48
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:52:21+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Merchant","phone":"639123456789"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203157,"client_order_id":null,"address":"32nd
49
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:52:21+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Reciever","phone":"639123456789"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false},{"order_id":77799,"order_name":"77799","vehicle_type_id":8,"created_datetime":"2020-05-12T20:28:12+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203150,"client_order_id":null,"address":"Zurich
50
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:58:12+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
51
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203151,"client_order_id":null,"address":"32nd
52
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:58:12+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
53
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false},{"order_id":77778,"order_name":"77778","vehicle_type_id":8,"created_datetime":"2020-05-12T17:32:16+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203114,"client_order_id":null,"address":"Zurich
54
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:32:16+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
55
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203115,"client_order_id":null,"address":"32nd
56
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:32:16+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
57
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false},{"order_id":77777,"order_name":"77777","vehicle_type_id":8,"created_datetime":"2020-05-12T17:13:08+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203112,"client_order_id":null,"address":"Zurich
58
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:43:08+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
59
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203113,"client_order_id":null,"address":"32nd
60
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:43:08+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
61
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false}],"orders_count":4}'
62
+ http_version: null
63
+ recorded_at: Wed, 13 May 2020 14:48:08 GMT
64
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://robotapitest.mrspeedy.ph/api/business/1.1/orders?status=completed
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"status":"completed"}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - robotapitest.mrspeedy.ph
18
+ X-Dv-Auth-Token:
19
+ - 70B4ABCA8A35AC50E1585E27F217DF160F740D46
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Wed, 13 May 2020 14:47:45 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Vary:
36
+ - Accept-Encoding
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Xss-Protection:
42
+ - 1; mode=block;
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: '{"is_successful":true,"orders":[],"orders_count":0}'
48
+ http_version: null
49
+ recorded_at: Wed, 13 May 2020 14:47:45 GMT
50
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://robotapitest.mrspeedy.ph/api/business/1.1/orders?count=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"count":1}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - robotapitest.mrspeedy.ph
18
+ X-Dv-Auth-Token:
19
+ - 70B4ABCA8A35AC50E1585E27F217DF160F740D46
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Wed, 13 May 2020 14:47:47 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Vary:
36
+ - Accept-Encoding
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Xss-Protection:
42
+ - 1; mode=block;
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: '{"is_successful":true,"orders":[{"order_id":77802,"order_name":"77802","vehicle_type_id":8,"created_datetime":"2020-05-12T21:22:21+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203156,"client_order_id":null,"address":"Zurich
48
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:52:21+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Merchant","phone":"639123456789"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203157,"client_order_id":null,"address":"32nd
49
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:52:21+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Reciever","phone":"639123456789"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false}],"orders_count":4}'
50
+ http_version: null
51
+ recorded_at: Wed, 13 May 2020 14:47:47 GMT
52
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://robotapitest.mrspeedy.ph/api/business/1.1/orders?offset=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"offset":1}'
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - robotapitest.mrspeedy.ph
18
+ X-Dv-Auth-Token:
19
+ - 70B4ABCA8A35AC50E1585E27F217DF160F740D46
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Wed, 13 May 2020 14:47:46 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Vary:
36
+ - Accept-Encoding
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Content-Type-Options:
40
+ - nosniff
41
+ X-Xss-Protection:
42
+ - 1; mode=block;
43
+ Strict-Transport-Security:
44
+ - max-age=31536000; includeSubDomains
45
+ body:
46
+ encoding: ASCII-8BIT
47
+ string: '{"is_successful":true,"orders":[{"order_id":77799,"order_name":"77799","vehicle_type_id":8,"created_datetime":"2020-05-12T20:28:12+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203150,"client_order_id":null,"address":"Zurich
48
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:58:12+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
49
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203151,"client_order_id":null,"address":"32nd
50
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:58:12+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
51
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false},{"order_id":77778,"order_name":"77778","vehicle_type_id":8,"created_datetime":"2020-05-12T17:32:16+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203114,"client_order_id":null,"address":"Zurich
52
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:32:16+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
53
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203115,"client_order_id":null,"address":"32nd
54
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:32:16+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
55
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false},{"order_id":77777,"order_name":"77777","vehicle_type_id":8,"created_datetime":"2020-05-12T17:13:08+08:00","finish_datetime":null,"status":"available","status_description":"Available","matter":"Food","total_weight_kg":0,"is_client_notification_enabled":false,"is_contact_person_notification_enabled":false,"loaders_count":0,"backpayment_details":null,"points":[{"point_type":"plain","point_id":203112,"client_order_id":null,"address":"Zurich
56
+ Ave, Matandang Balara, Quezon City, Metro Manila, Philippines","latitude":"14.6710069","longitude":"121.0944076","required_start_datetime":"2020-05-13T22:43:08+08:00","required_finish_datetime":"2020-05-14T00:00:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
57
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null},{"point_type":"plain","point_id":203113,"client_order_id":null,"address":"32nd
58
+ St. cor. 9th Ave, Taguig, Metro Manila, 32nd St, Taguig, Metro Manila, Philippines","latitude":"14.5528233","longitude":"121.0519364","required_start_datetime":"2020-05-13T22:43:08+08:00","required_finish_datetime":"2020-05-14T00:30:00+08:00","arrival_start_datetime":null,"arrival_finish_datetime":null,"courier_visit_datetime":null,"contact_person":{"name":"Admin
59
+ One","phone":"639277876287"},"taking_amount":"0.00","buyout_amount":"0.00","note":null,"packages":[],"is_cod_cash_voucher_required":false,"is_order_payment_here":false,"building_number":null,"entrance_number":null,"intercom_code":null,"floor_number":null,"apartment_number":null,"invisible_mile_navigation_instructions":null}],"payment_amount":"170.00","delivery_fee_amount":"170.00","intercity_delivery_fee_amount":"0.00","weight_fee_amount":"0.00","insurance_amount":"0.00","insurance_fee_amount":"0.00","loading_fee_amount":"0.00","money_transfer_fee_amount":"0.00","suburban_delivery_fee_amount":"0.00","overnight_fee_amount":"0.00","discount_amount":"0.00","backpayment_amount":"0.00","cod_fee_amount":"0.00","backpayment_photo_url":null,"itinerary_document_url":null,"waybill_document_url":null,"courier":null,"is_motobox_required":false}],"orders_count":4}'
60
+ http_version: null
61
+ recorded_at: Wed, 13 May 2020 14:47:46 GMT
62
+ recorded_with: VCR 5.1.0
@@ -10,6 +10,19 @@ module MrSpeedyRuby
10
10
  PRODUCTION_BASE_URL="http://robot.mrspeedy.ph".freeze
11
11
  STAGING_BASE_URL="https://robotapitest.mrspeedy.ph".freeze
12
12
 
13
+ # Constructor method
14
+ # @since 1.0.0-alpha.3
15
+ #
16
+ # @attr_reader [String] token authentication token
17
+ # @attr_reader [String] version api version
18
+ attr_reader :token, :version
19
+
20
+ def initialize(token:, version: "1.1")
21
+ @token = token
22
+ @version = version
23
+ end
24
+
25
+
13
26
  # Endpoint Generator
14
27
  # @since v0.1.0
15
28
  #
@@ -38,6 +51,20 @@ module MrSpeedyRuby
38
51
  response_body
39
52
  end
40
53
 
54
+ # Send Get Request
55
+ # @since 1.0.0-alpha.3
56
+ # @param endpoint [String] request endpoint
57
+ # @param token [String] app token
58
+ # @param payload [Hash] message payload
59
+ #
60
+ # @return [Json] response
61
+ def get(endpoint:, token:, payload: {})
62
+ response = send_request("get", endpoint, token, payload)
63
+
64
+ response_body = JSON.parse(response.body)
65
+ response_body
66
+ end
67
+
41
68
  private
42
69
 
43
70
  # Request sender
@@ -56,6 +83,8 @@ module MrSpeedyRuby
56
83
  request = if method == "post"
57
84
  Net::HTTP::Post.new(uri)
58
85
  else
86
+ # Encode payload as query parameters for GET method
87
+ uri.query = URI.encode_www_form( payload )
59
88
  Net::HTTP::Get.new(uri)
60
89
  end
61
90
 
@@ -1,4 +1,5 @@
1
1
  require "mr_speedy_ruby/base"
2
+ require "mr_speedy_ruby/order"
2
3
  require "mr_speedy_ruby/lib/hash_refinement"
3
4
 
4
5
  module MrSpeedyRuby
@@ -11,15 +12,6 @@ module MrSpeedyRuby
11
12
  CAR = 7.freeze
12
13
  MOTORBIKE = 8.freeze
13
14
 
14
- # @attr_reader [String] token authentication token
15
- # @attr_reader [String] version api version
16
- attr_reader :token, :version
17
-
18
- def initialize(token:, version: "1.1")
19
- @token = token
20
- @version = version
21
- end
22
-
23
15
  # Delivery Fee Calculation
24
16
  # @since 0.1.0
25
17
  #
@@ -96,6 +88,24 @@ module MrSpeedyRuby
96
88
  post(endpoint: url, token: @token, payload: payload)
97
89
  end
98
90
 
91
+ # Order List
92
+ # @since 1.0.0-alpha.3
93
+ #
94
+ # @param [Boolean] sandbox sandbox mode
95
+ # @param [Hash] payload order query payload
96
+ # @param payload [Integer, Array<Integer>] :order_id order id
97
+ # @param payload [String] :status order status
98
+ # @param payload [Integer] :offset order record offset count
99
+ # @param payload [Integer] :count order record limit
100
+ #
101
+ # @see https://apitest.mrspeedy.ph/business-api/doc#orders
102
+ #
103
+ # @return [Json]
104
+ def orders(sandbox: false, payload: {})
105
+ order_client = MrSpeedyRuby::Order.new(token: @token, version: @version)
106
+ order_client.orders(sandbox: sandbox, payload: payload)
107
+ end
108
+
99
109
  private
100
110
 
101
111
  # Options Required Keys
@@ -0,0 +1,27 @@
1
+ require "mr_speedy_ruby/base"
2
+
3
+ module MrSpeedyRuby
4
+ # Mr Speedy API Order
5
+ # @since 1.0.0-alpha.3
6
+ class Order < Base
7
+ # Order List
8
+ # @since 1.0.0-alpha.3
9
+ #
10
+ # @param [Boolean] sandbox sandbox mode
11
+ # @param [Hash] payload order query payload
12
+ # @param payload [Integer, Array<Integer>] :order_id order id
13
+ # @param payload [String] :status order status
14
+ # @param payload [Integer] :offset order record offset count
15
+ # @param payload [Integer] :count order record limit
16
+ #
17
+ # @see https://apitest.mrspeedy.ph/business-api/doc#orders
18
+ #
19
+ # @return [Json]
20
+ def orders(payload: {}, sandbox: false)
21
+ endpoint = "/api/business/#{version}/orders"
22
+ url = build_url(endpoint, sandbox)
23
+
24
+ get(endpoint: url, token: token, payload: payload)
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module MrSpeedyRuby
2
- VERSION = "1.0.0-alpha.2"
2
+ VERSION = "1.0.0-alpha.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mr_speedy_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.2
4
+ version: 1.0.0.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter John Alvarado
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,11 +128,16 @@ files:
128
128
  - bin/console
129
129
  - bin/setup
130
130
  - fixtures/vcr_cassettes/delivery_fee.yml
131
+ - fixtures/vcr_cassettes/orders.yml
132
+ - fixtures/vcr_cassettes/orders_by_status.yml
133
+ - fixtures/vcr_cassettes/orders_with_limit.yml
134
+ - fixtures/vcr_cassettes/orders_with_offset.yml
131
135
  - fixtures/vcr_cassettes/place_order.yml
132
136
  - lib/mr_speedy_ruby.rb
133
137
  - lib/mr_speedy_ruby/base.rb
134
138
  - lib/mr_speedy_ruby/client.rb
135
139
  - lib/mr_speedy_ruby/lib/hash_refinement.rb
140
+ - lib/mr_speedy_ruby/order.rb
136
141
  - lib/mr_speedy_ruby/version.rb
137
142
  - mr_speedy_ruby.gemspec
138
143
  homepage: https://github.com/redjoker011/mr_speedy_ruby