noths 0.1.0

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 (114) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/README.md +149 -0
  5. data/Rakefile +8 -0
  6. data/bin/generate_gem +18 -0
  7. data/bin/refresh_schemas +94 -0
  8. data/docs/AcceptanceBulkModel.md +11 -0
  9. data/docs/Currency.md +11 -0
  10. data/docs/DeclineBulkModel.md +9 -0
  11. data/docs/DeliveryAddress.md +13 -0
  12. data/docs/DeliveryService.md +9 -0
  13. data/docs/DeliveryZone.md +9 -0
  14. data/docs/DispatchBulkModel.md +12 -0
  15. data/docs/DispatchNotesBulkModel.md +8 -0
  16. data/docs/Enquiry.md +10 -0
  17. data/docs/EnquiryMessage.md +8 -0
  18. data/docs/Error.md +9 -0
  19. data/docs/Financials.md +25 -0
  20. data/docs/FinancialsDetails.md +10 -0
  21. data/docs/ImageUrl.md +13 -0
  22. data/docs/Item.md +15 -0
  23. data/docs/ItemFinancials.md +13 -0
  24. data/docs/Link.md +10 -0
  25. data/docs/ManualPayment.md +11 -0
  26. data/docs/Money.md +9 -0
  27. data/docs/Order.md +53 -0
  28. data/docs/OrderDetail.md +9 -0
  29. data/docs/OrderDetailsBulkModel.md +8 -0
  30. data/docs/OrderIndex.md +10 -0
  31. data/docs/OrderRefund.md +8 -0
  32. data/docs/OrdersApi.md +796 -0
  33. data/docs/Product.md +12 -0
  34. data/docs/ProductOption.md +9 -0
  35. data/docs/RefundResponse.md +10 -0
  36. data/docs/RefundsApi.md +69 -0
  37. data/docs/SearchResultMeta.md +9 -0
  38. data/docs/User.md +10 -0
  39. data/lib/noths.rb +70 -0
  40. data/lib/noths/api/orders_api.rb +819 -0
  41. data/lib/noths/api/refunds_api.rb +88 -0
  42. data/lib/noths/api_client.rb +389 -0
  43. data/lib/noths/api_error.rb +38 -0
  44. data/lib/noths/configuration.rb +209 -0
  45. data/lib/noths/models/acceptance_bulk_model.rb +233 -0
  46. data/lib/noths/models/currency.rb +235 -0
  47. data/lib/noths/models/decline_bulk_model.rb +208 -0
  48. data/lib/noths/models/delivery_address.rb +263 -0
  49. data/lib/noths/models/delivery_service.rb +207 -0
  50. data/lib/noths/models/delivery_zone.rb +207 -0
  51. data/lib/noths/models/dispatch_bulk_model.rb +236 -0
  52. data/lib/noths/models/dispatch_notes_bulk_model.rb +194 -0
  53. data/lib/noths/models/enquiry.rb +223 -0
  54. data/lib/noths/models/enquiry_message.rb +193 -0
  55. data/lib/noths/models/error.rb +207 -0
  56. data/lib/noths/models/financials.rb +433 -0
  57. data/lib/noths/models/financials_details.rb +221 -0
  58. data/lib/noths/models/image_url.rb +263 -0
  59. data/lib/noths/models/item.rb +293 -0
  60. data/lib/noths/models/item_financials.rb +263 -0
  61. data/lib/noths/models/link.rb +222 -0
  62. data/lib/noths/models/manual_payment.rb +235 -0
  63. data/lib/noths/models/money.rb +207 -0
  64. data/lib/noths/models/order.rb +812 -0
  65. data/lib/noths/models/order_detail.rb +207 -0
  66. data/lib/noths/models/order_details_bulk_model.rb +194 -0
  67. data/lib/noths/models/order_index.rb +225 -0
  68. data/lib/noths/models/order_refund.rb +193 -0
  69. data/lib/noths/models/product.rb +249 -0
  70. data/lib/noths/models/product_option.rb +207 -0
  71. data/lib/noths/models/refund_response.rb +223 -0
  72. data/lib/noths/models/search_result_meta.rb +207 -0
  73. data/lib/noths/models/user.rb +221 -0
  74. data/lib/noths/version.rb +15 -0
  75. data/noths.gemspec +45 -0
  76. data/schemas/api-docs.json +26 -0
  77. data/schemas/orders.json +2013 -0
  78. data/schemas/refunds.json +128 -0
  79. data/spec/api/orders_api_spec.rb +239 -0
  80. data/spec/api/refunds_api_spec.rb +50 -0
  81. data/spec/api_client_spec.rb +226 -0
  82. data/spec/configuration_spec.rb +42 -0
  83. data/spec/models/acceptance_bulk_model_spec.rb +60 -0
  84. data/spec/models/currency_spec.rb +60 -0
  85. data/spec/models/decline_bulk_model_spec.rb +48 -0
  86. data/spec/models/delivery_address_spec.rb +72 -0
  87. data/spec/models/delivery_service_spec.rb +48 -0
  88. data/spec/models/delivery_zone_spec.rb +48 -0
  89. data/spec/models/dispatch_bulk_model_spec.rb +66 -0
  90. data/spec/models/dispatch_notes_bulk_model_spec.rb +42 -0
  91. data/spec/models/enquiry_message_spec.rb +42 -0
  92. data/spec/models/enquiry_spec.rb +54 -0
  93. data/spec/models/error_spec.rb +48 -0
  94. data/spec/models/financials_details_spec.rb +54 -0
  95. data/spec/models/financials_spec.rb +144 -0
  96. data/spec/models/image_url_spec.rb +72 -0
  97. data/spec/models/item_financials_spec.rb +72 -0
  98. data/spec/models/item_spec.rb +84 -0
  99. data/spec/models/link_spec.rb +54 -0
  100. data/spec/models/manual_payment_spec.rb +60 -0
  101. data/spec/models/money_spec.rb +48 -0
  102. data/spec/models/order_detail_spec.rb +48 -0
  103. data/spec/models/order_details_bulk_model_spec.rb +42 -0
  104. data/spec/models/order_index_spec.rb +54 -0
  105. data/spec/models/order_refund_spec.rb +42 -0
  106. data/spec/models/order_spec.rb +312 -0
  107. data/spec/models/product_option_spec.rb +48 -0
  108. data/spec/models/product_spec.rb +66 -0
  109. data/spec/models/refund_response_spec.rb +54 -0
  110. data/spec/models/search_result_meta_spec.rb +48 -0
  111. data/spec/models/user_spec.rb +54 -0
  112. data/spec/spec_helper.rb +111 -0
  113. data/swagger_config.json +16 -0
  114. metadata +370 -0
@@ -0,0 +1,128 @@
1
+ {
2
+ "apiVersion": "1.0",
3
+ "swaggerVersion": "1.2",
4
+ "basePath": "/",
5
+ "resourcePath": "refunds",
6
+ "apis": [
7
+ {
8
+ "path": "/api/v1/orders/{order_id}/refunds",
9
+ "operations": [
10
+ {
11
+ "parameters": [
12
+ {
13
+ "paramType": "path",
14
+ "name": "order_id",
15
+ "type": "integer",
16
+ "description": "Order id",
17
+ "required": true
18
+ },
19
+ {
20
+ "paramType": "form",
21
+ "name": "refund_reason",
22
+ "type": "string",
23
+ "description": "Customer will see this message",
24
+ "required": true
25
+ },
26
+ {
27
+ "paramType": "form",
28
+ "name": "cents",
29
+ "type": "integer",
30
+ "description": null,
31
+ "required": true
32
+ }
33
+ ],
34
+ "summary": "Refund an order",
35
+ "notes": "Refunds all or part of an order",
36
+ "responseMessages": [
37
+ {
38
+ "code": 200,
39
+ "responseModel": "RefundResponse",
40
+ "message": " A status code of 200 indicates that the order was eligible to be refunded and is expected to be processed\n successfully. This is not a guarantee that the order will be refunded. Processing a refund is not instantaneous\n and may take some time.\n"
41
+ },
42
+ {
43
+ "code": 400,
44
+ "responseModel": null,
45
+ "message": "Bad Request"
46
+ },
47
+ {
48
+ "code": 401,
49
+ "responseModel": null,
50
+ "message": "Unauthorized"
51
+ },
52
+ {
53
+ "code": 404,
54
+ "responseModel": null,
55
+ "message": "Not Found"
56
+ }
57
+ ],
58
+ "method": "post",
59
+ "nickname": "Refunds#create",
60
+ "authorizations": {
61
+ "token": [
62
+
63
+ ]
64
+ }
65
+ }
66
+ ]
67
+ }
68
+ ],
69
+ "models": {
70
+ "RefundResponse": {
71
+ "id": "RefundResponse",
72
+ "required": [
73
+ "status",
74
+ "errors",
75
+ "order_refund"
76
+ ],
77
+ "properties": {
78
+ "status": {
79
+ "type": "integer",
80
+ "description": null
81
+ },
82
+ "errors": {
83
+ "type": "array",
84
+ "description": null,
85
+ "items": {
86
+ "$ref": "Error"
87
+ }
88
+ },
89
+ "order_refund": {
90
+ "type": "OrderRefund",
91
+ "description": null,
92
+ "items": {
93
+ "$ref": "OrderRefund"
94
+ }
95
+ }
96
+ }
97
+ },
98
+ "OrderRefund": {
99
+ "id": "OrderRefund",
100
+ "required": [
101
+ "id"
102
+ ],
103
+ "properties": {
104
+ "id": {
105
+ "type": "integer",
106
+ "description": null
107
+ }
108
+ }
109
+ },
110
+ "Error": {
111
+ "id": "Error",
112
+ "required": [
113
+ "code",
114
+ "title"
115
+ ],
116
+ "properties": {
117
+ "code": {
118
+ "type": "string",
119
+ "description": null
120
+ },
121
+ "title": {
122
+ "type": "string",
123
+ "description": null
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #Noths
3
+
4
+ #www.notonthehighstreet.com API client
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Noths::OrdersApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'OrdersApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = Noths::OrdersApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of OrdersApi' do
30
+ it 'should create an instance of OrdersApi' do
31
+ expect(@instance).to be_instance_of(Noths::OrdersApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for api_v1_orders_acceptance
36
+ # Accept an order
37
+ # Accept an order that is in the placed state. Note: In rare instances orders may not transition to the 'accepted' state immediately.
38
+ # @param token Authentication credential
39
+ # @param id Order id
40
+ # @param estimated_delivery_date 'yyyy-mm-dd'
41
+ # @param estimated_dispatch_at 'yyyy-mm-dd'
42
+ # @param [Hash] opts the optional parameters
43
+ # @option opts [String] :confirmation_note
44
+ # @return [nil]
45
+ describe 'api_v1_orders_acceptance test' do
46
+ it "should work" do
47
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
48
+ end
49
+ end
50
+
51
+ # unit tests for api_v1_orders_acceptance_bulk
52
+ # Accept multiple orders
53
+ # Returns an array of hashes containing order ids and status codes. A status code of 200 indicates that the order was eligible to be accepted and is expected to be processed successfully. This is not a guarantee that the order will be accepted. Processing acceptance is not instantaneous and may take some time while funds are captured. Example response: <pre> [ { \"id\": 12, \"status\": 200, \"errors\": [] }, { \"id\": 22, \"status\": 404, \"errors\": [ { \"code\": \"RESOURCE_NOT_FOUND\", \"title\": \"Couldn't find the requested resource\" } ] } ] </pre>
54
+ # @param token Authentication credential
55
+ # @param
56
+ # @param [Hash] opts the optional parameters
57
+ # @return [nil]
58
+ describe 'api_v1_orders_acceptance_bulk test' do
59
+ it "should work" do
60
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
61
+ end
62
+ end
63
+
64
+ # unit tests for api_v1_orders_decline
65
+ # Decline an order
66
+ # Declines an order that is in the placed state
67
+ # @param token Authentication credential
68
+ # @param id Order id
69
+ # @param decline_reason
70
+ # @param [Hash] opts the optional parameters
71
+ # @return [nil]
72
+ describe 'api_v1_orders_decline test' do
73
+ it "should work" do
74
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
75
+ end
76
+ end
77
+
78
+ # unit tests for api_v1_orders_decline_bulk
79
+ # Decline multiple orders
80
+ # Returns an array of hashes containing order ids and status codes. A status code of 200 indicates a successful update whereas a code of 400 indicates failure. Example response: <pre> [ { \"id\": 12, \"status\": 200, \"errors\": [] }, { \"id\": 22, \"status\": 404, \"errors\": [ { \"code\": \"RESOURCE_NOT_FOUND\", \"title\": \"Couldn't find the requested resource\" } ] } ] </pre>
81
+ # @param token Authentication credential
82
+ # @param
83
+ # @param [Hash] opts the optional parameters
84
+ # @return [nil]
85
+ describe 'api_v1_orders_decline_bulk test' do
86
+ it "should work" do
87
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
88
+ end
89
+ end
90
+
91
+ # unit tests for api_v1_orders_dispatch_note
92
+ # Generate a dispatch note pdf or gift note pdf.
93
+ # Force the kind of document by passing the force_type parameter. A gift note can only be printed for an order that is a gift, which will be the default behaviour.<p/>Here is an example of how to obtain a pdf using curl: <pre>curl -XPOST [URL] > document.pdf</pre>
94
+ # @param token Authentication credential
95
+ # @param id Order id
96
+ # @param [Hash] opts the optional parameters
97
+ # @option opts [String] :force_type Type of document
98
+ # @return [nil]
99
+ describe 'api_v1_orders_dispatch_note test' do
100
+ it "should work" do
101
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
102
+ end
103
+ end
104
+
105
+ # unit tests for api_v1_orders_dispatch_notes_bulk
106
+ # Generate pdf with dispatch note for each order
107
+ # <p/> Here is an example of how to obtain a pdf using curl: <pre>curl -H \"Content-Type: application/json\" -d '[{\"id\": 123}, {\"id\": 456}]' -XPOST [URL] > document.pdf</pre><p/> Ensure that the Content-Type header is set to \"Content-Type: application/json\".<p/>
108
+ # @param token Authentication credential
109
+ # @param
110
+ # @param [Hash] opts the optional parameters
111
+ # @return [nil]
112
+ describe 'api_v1_orders_dispatch_notes_bulk test' do
113
+ it "should work" do
114
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
115
+ end
116
+ end
117
+
118
+ # unit tests for api_v1_orders_dispatch_order
119
+ # Dispatch an order
120
+ # Dispatches an order that is in an accepted state and has also had its dispatch note printed
121
+ # @param token Authentication credential
122
+ # @param id Order id
123
+ # @param estimated_delivery_date 'yyyy-mm-dd'
124
+ # @param [Hash] opts the optional parameters
125
+ # @option opts [BOOLEAN] :resolve_enquiry
126
+ # @option opts [String] :tracking_number
127
+ # @option opts [String] :parcel_tracking_url
128
+ # @option opts [BOOLEAN] :ignore_unresolved_enquiries Defaults to false
129
+ # @return [nil]
130
+ describe 'api_v1_orders_dispatch_order test' do
131
+ it "should work" do
132
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
133
+ end
134
+ end
135
+
136
+ # unit tests for api_v1_orders_dispatch_orders_bulk
137
+ # Dispatch multiple orders
138
+ # Returns an array of hashes containing order ids and status codes. A status code of 200 indicates a successful update whereas a code of 400 indicates failure. Example response: <pre> [ { \"id\": 12, \"status\": 200, \"errors\": [] }, { \"id\": 22, \"status\": 404, \"errors\": [ { \"code\": \"RESOURCE_NOT_FOUND\", \"title\": \"Couldn't find the requested resource\" } ] } ] </pre>
139
+ # @param token Authentication credential
140
+ # @param
141
+ # @param [Hash] opts the optional parameters
142
+ # @option opts [BOOLEAN] :ignore_unresolved_enquiries Defaults to false
143
+ # @return [nil]
144
+ describe 'api_v1_orders_dispatch_orders_bulk test' do
145
+ it "should work" do
146
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
147
+ end
148
+ end
149
+
150
+ # unit tests for api_v1_orders_index
151
+ # Fetch orders
152
+ # Lists orders descending by placed at time by default.<p/>If you just want a count, use per_page=0 and offset=0 .
153
+ # @param token Authentication credential
154
+ # @param [Hash] opts the optional parameters
155
+ # @option opts [DateTime] :customer_expected_delivery_date_from Earliest customer_expected_delivery_date datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
156
+ # @option opts [DateTime] :customer_expected_delivery_date_to Latest customer_expected_delivery_date datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
157
+ # @option opts [String] :delivery_service_code Delivery service code
158
+ # @option opts [String] :delivery_zone_ids List of delivery zone ids
159
+ # @option opts [String] :dir Direction (defaults to desc)
160
+ # @option opts [BOOLEAN] :dispatch_note_viewed
161
+ # @option opts [String] :enquiry_state Enquiry state where `unresolved` includes `opened`, `acknowledged` and `overdue`
162
+ # @option opts [DateTime] :estimated_delivery_date_from Earliest estimated_delivery_date datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
163
+ # @option opts [DateTime] :estimated_delivery_date_to Latest estimated_delivery_date datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
164
+ # @option opts [DateTime] :estimated_dispatch_at_from Earliest estimated_dispatch_at datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
165
+ # @option opts [DateTime] :estimated_dispatch_at_to Latest estimated_dispatch_at datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'
166
+ # @option opts [DateTime] :updated_at_from Earliest updated_at datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'. Is not changed on nested resource updates eg 'Enquiry'
167
+ # @option opts [DateTime] :updated_at_to Latest updated_at datetime - format iso8601 eg '2011-10-05T22:26:12-04:00'. Is not changed on nested resource updates eg 'Enquiry'
168
+ # @option opts [BOOLEAN] :gift
169
+ # @option opts [BOOLEAN] :unresolved_enquiry
170
+ # @option opts [String] :ids List of order ids
171
+ # @option opts [Integer] :offset
172
+ # @option opts [Integer] :per_page Defaults to 30, maximum is 250
173
+ # @option opts [String] :product_ids List of product ids
174
+ # @option opts [String] :query Matches your query to information related to your orders
175
+ # @option opts [BOOLEAN] :repeat_customer
176
+ # @option opts [String] :sort Defaults to placed_at
177
+ # @option opts [String] :state State
178
+ # @return [OrderIndex]
179
+ describe 'api_v1_orders_index test' do
180
+ it "should work" do
181
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
182
+ end
183
+ end
184
+
185
+ # unit tests for api_v1_orders_invoice
186
+ # Generate a vat invoice pdf.
187
+ # <p>Invoices are currently only applicable for the UK site</p>Here is an example of how to obtain a pdf using curl: <pre>curl -XPOST [URL] > document.pdf</pre>
188
+ # @param token Authentication credential
189
+ # @param id Order id
190
+ # @param type Type of invoice
191
+ # @param [Hash] opts the optional parameters
192
+ # @return [nil]
193
+ describe 'api_v1_orders_invoice test' do
194
+ it "should work" do
195
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
196
+ end
197
+ end
198
+
199
+ # unit tests for api_v1_orders_order_details
200
+ # Generate an order details pdf
201
+ # Here is an example of how to obtain a pdf using curl: <pre>curl -XPOST [URL] > document.pdf</pre>
202
+ # @param token Authentication credential
203
+ # @param id Order id
204
+ # @param [Hash] opts the optional parameters
205
+ # @return [nil]
206
+ describe 'api_v1_orders_order_details test' do
207
+ it "should work" do
208
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
209
+ end
210
+ end
211
+
212
+ # unit tests for api_v1_orders_order_details_bulk
213
+ # Generate pdf with order details for each order
214
+ # <p/> Here is an example of how to obtain a pdf using curl: <pre>curl -H \"Content-Type: application/json\" -d '[{\"id\": 123}, {\"id\": 456}]' -XPOST [URL] > document.pdf</pre><p/> Ensure that the Content-Type header is set to \"Content-Type: application/json\".<p/>
215
+ # @param token Authentication credential
216
+ # @param
217
+ # @param [Hash] opts the optional parameters
218
+ # @return [nil]
219
+ describe 'api_v1_orders_order_details_bulk test' do
220
+ it "should work" do
221
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
222
+ end
223
+ end
224
+
225
+ # unit tests for api_v1_orders_show
226
+ # Fetch a single Order
227
+ #
228
+ # @param token Authentication credential
229
+ # @param id Order Id
230
+ # @param [Hash] opts the optional parameters
231
+ # @option opts [String] :include Comma separated list of nodes to expand. Currently the available values are: <br /><b style=\"margin-left: 10px\">financials</b> <p style=\"margin-left: 20px\"> Additional financial data about this order, eg: commission and discount amounts. </p>
232
+ # @return [Order]
233
+ describe 'api_v1_orders_show test' do
234
+ it "should work" do
235
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
236
+ end
237
+ end
238
+
239
+ end
@@ -0,0 +1,50 @@
1
+ =begin
2
+ #Noths
3
+
4
+ #www.notonthehighstreet.com API client
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Noths::RefundsApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'RefundsApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = Noths::RefundsApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of RefundsApi' do
30
+ it 'should create an instance of RefundsApi' do
31
+ expect(@instance).to be_instance_of(Noths::RefundsApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for api_v1_refunds_create
36
+ # Refund an order
37
+ # Refunds all or part of an order
38
+ # @param token Authentication credential
39
+ # @param order_id Order id
40
+ # @param refund_reason Customer will see this message
41
+ # @param cents
42
+ # @param [Hash] opts the optional parameters
43
+ # @return [RefundResponse]
44
+ describe 'api_v1_refunds_create test' do
45
+ it "should work" do
46
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #Noths
3
+
4
+ #www.notonthehighstreet.com API client
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe Noths::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ Noths.configure { |c| c.host = 'http://example.com' }
21
+ expect(Noths::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ Noths.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(Noths::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ Noths.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(Noths::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ Noths.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(Noths::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ Noths.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(Noths::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ Noths.configure { |c| c.base_path = nil }
48
+ expect(Noths::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "params_encoding in #build_request" do
55
+ let(:config) { Noths::Configuration.new }
56
+ let(:api_client) { Noths::ApiClient.new(config) }
57
+
58
+ it "defaults to nil" do
59
+ expect(Noths::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it "can be customized" do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe "timeout in #build_request" do
74
+ let(:config) { Noths::Configuration.new }
75
+ let(:api_client) { Noths::ApiClient.new(config) }
76
+
77
+ it "defaults to 0" do
78
+ expect(Noths::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it "can be customized" do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+ describe "#deserialize" do
93
+ it "handles Array<Integer>" do
94
+ api_client = Noths::ApiClient.new
95
+ headers = {'Content-Type' => 'application/json'}
96
+ response = double('response', headers: headers, body: '[12, 34]')
97
+ data = api_client.deserialize(response, 'Array<Integer>')
98
+ expect(data).to be_instance_of(Array)
99
+ expect(data).to eq([12, 34])
100
+ end
101
+
102
+ it "handles Array<Array<Integer>>" do
103
+ api_client = Noths::ApiClient.new
104
+ headers = {'Content-Type' => 'application/json'}
105
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
106
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
107
+ expect(data).to be_instance_of(Array)
108
+ expect(data).to eq([[12, 34], [56]])
109
+ end
110
+
111
+ it "handles Hash<String, String>" do
112
+ api_client = Noths::ApiClient.new
113
+ headers = {'Content-Type' => 'application/json'}
114
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
115
+ data = api_client.deserialize(response, 'Hash<String, String>')
116
+ expect(data).to be_instance_of(Hash)
117
+ expect(data).to eq({:message => 'Hello'})
118
+ end
119
+ end
120
+
121
+ describe "#object_to_hash" do
122
+ it "ignores nils and includes empty arrays" do
123
+ # uncomment below to test object_to_hash for model
124
+ #api_client = Noths::ApiClient.new
125
+ #_model = Noths::ModelName.new
126
+ # update the model attribute below
127
+ #_model.id = 1
128
+ # update the expected value (hash) below
129
+ #expected = {id: 1, name: '', tags: []}
130
+ #expect(api_client.object_to_hash(_model)).to eq(expected)
131
+ end
132
+ end
133
+
134
+ describe "#build_collection_param" do
135
+ let(:param) { ['aa', 'bb', 'cc'] }
136
+ let(:api_client) { Noths::ApiClient.new }
137
+
138
+ it "works for csv" do
139
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
140
+ end
141
+
142
+ it "works for ssv" do
143
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
144
+ end
145
+
146
+ it "works for tsv" do
147
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
148
+ end
149
+
150
+ it "works for pipes" do
151
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
152
+ end
153
+
154
+ it "works for multi" do
155
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
156
+ end
157
+
158
+ it "fails for invalid collection format" do
159
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160
+ end
161
+ end
162
+
163
+ describe "#json_mime?" do
164
+ let(:api_client) { Noths::ApiClient.new }
165
+
166
+ it "works" do
167
+ expect(api_client.json_mime?(nil)).to eq false
168
+ expect(api_client.json_mime?('')).to eq false
169
+
170
+ expect(api_client.json_mime?('application/json')).to eq true
171
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
172
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
173
+
174
+ expect(api_client.json_mime?('application/xml')).to eq false
175
+ expect(api_client.json_mime?('text/plain')).to eq false
176
+ expect(api_client.json_mime?('application/jsonp')).to eq false
177
+ end
178
+ end
179
+
180
+ describe "#select_header_accept" do
181
+ let(:api_client) { Noths::ApiClient.new }
182
+
183
+ it "works" do
184
+ expect(api_client.select_header_accept(nil)).to be_nil
185
+ expect(api_client.select_header_accept([])).to be_nil
186
+
187
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
188
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
189
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
190
+
191
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
192
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
193
+ end
194
+ end
195
+
196
+ describe "#select_header_content_type" do
197
+ let(:api_client) { Noths::ApiClient.new }
198
+
199
+ it "works" do
200
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
201
+ expect(api_client.select_header_content_type([])).to eq('application/json')
202
+
203
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
204
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
205
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
206
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
207
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
208
+ end
209
+ end
210
+
211
+ describe "#sanitize_filename" do
212
+ let(:api_client) { Noths::ApiClient.new }
213
+
214
+ it "works" do
215
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
216
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
224
+ end
225
+ end
226
+ end