pwinty 3.0.5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +17 -0
- data/.devcontainer/base.Dockerfile +43 -0
- data/.devcontainer/devcontainer.json +37 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +1 -1
- data/Gemfile.lock +82 -63
- data/README.md +50 -99
- data/lib/pwinty/api_models/order.rb +114 -0
- data/lib/pwinty/api_models/order_asset.rb +7 -0
- data/lib/pwinty/api_models/order_charge.rb +5 -0
- data/lib/pwinty/api_models/order_cost.rb +7 -0
- data/lib/pwinty/api_models/order_item.rb +24 -0
- data/lib/pwinty/api_models/order_packing_slip.rb +7 -0
- data/lib/pwinty/api_models/order_recipient.rb +17 -0
- data/lib/pwinty/api_models/order_recipient_address.rb +11 -0
- data/lib/pwinty/api_models/order_shipment.rb +16 -0
- data/lib/pwinty/api_models/order_shipment_carrier.rb +6 -0
- data/lib/pwinty/api_models/order_shipment_fulfillment_location.rb +7 -0
- data/lib/pwinty/api_models/order_shipment_item.rb +6 -0
- data/lib/pwinty/api_models/order_status.rb +11 -0
- data/lib/pwinty/api_models/order_status_auth_details.rb +7 -0
- data/lib/pwinty/api_models/order_status_details.rb +10 -0
- data/lib/pwinty/api_models/order_status_issue.rb +11 -0
- data/lib/pwinty/api_models/order_tracking.rb +6 -0
- data/lib/pwinty/api_models/product.rb +19 -0
- data/lib/pwinty/api_models/product_dimensions.rb +8 -0
- data/lib/pwinty/api_models/product_variant.rb +8 -0
- data/lib/pwinty/base.rb +6 -6
- data/lib/pwinty/http_errors.rb +13 -11
- data/lib/pwinty/version.rb +1 -1
- data/lib/pwinty.rb +48 -49
- data/pwinty.gemspec +13 -13
- metadata +56 -39
- data/lib/pwinty/country.rb +0 -12
- data/lib/pwinty/image.rb +0 -24
- data/lib/pwinty/order.rb +0 -126
- data/lib/pwinty/order_status.rb +0 -17
- data/lib/pwinty/photo_status.rb +0 -8
- data/lib/pwinty/shipment.rb +0 -14
- data/lib/pwinty/shipping_info.rb +0 -9
metadata
CHANGED
@@ -1,99 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwinty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Harvey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '6.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '6.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.21'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.21'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: dotenv
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,57 +128,57 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
131
|
+
version: '0.4'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
138
|
+
version: '0.4'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: faraday
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0
|
145
|
+
version: '1.0'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '0
|
152
|
+
version: '1.0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: faraday_middleware
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '1.2'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '1.2'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: json
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: '2.
|
173
|
+
version: '2.6'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: '2.
|
181
|
-
description: This wraps the Pwinty API at version
|
180
|
+
version: '2.6'
|
181
|
+
description: This wraps the Pwinty API at version 4 and aims to make your ruby life
|
182
182
|
easier when interacting with the API.
|
183
183
|
email:
|
184
184
|
- tom@alush.co.uk
|
@@ -186,9 +186,13 @@ executables: []
|
|
186
186
|
extensions: []
|
187
187
|
extra_rdoc_files: []
|
188
188
|
files:
|
189
|
+
- ".devcontainer/Dockerfile"
|
190
|
+
- ".devcontainer/base.Dockerfile"
|
191
|
+
- ".devcontainer/devcontainer.json"
|
189
192
|
- ".env.sample"
|
190
193
|
- ".gitignore"
|
191
194
|
- ".rspec"
|
195
|
+
- ".rubocop.yml"
|
192
196
|
- ".travis.yml"
|
193
197
|
- CODE_OF_CONDUCT.md
|
194
198
|
- Gemfile
|
@@ -199,15 +203,28 @@ files:
|
|
199
203
|
- bin/console
|
200
204
|
- bin/setup
|
201
205
|
- lib/pwinty.rb
|
206
|
+
- lib/pwinty/api_models/order.rb
|
207
|
+
- lib/pwinty/api_models/order_asset.rb
|
208
|
+
- lib/pwinty/api_models/order_charge.rb
|
209
|
+
- lib/pwinty/api_models/order_cost.rb
|
210
|
+
- lib/pwinty/api_models/order_item.rb
|
211
|
+
- lib/pwinty/api_models/order_packing_slip.rb
|
212
|
+
- lib/pwinty/api_models/order_recipient.rb
|
213
|
+
- lib/pwinty/api_models/order_recipient_address.rb
|
214
|
+
- lib/pwinty/api_models/order_shipment.rb
|
215
|
+
- lib/pwinty/api_models/order_shipment_carrier.rb
|
216
|
+
- lib/pwinty/api_models/order_shipment_fulfillment_location.rb
|
217
|
+
- lib/pwinty/api_models/order_shipment_item.rb
|
218
|
+
- lib/pwinty/api_models/order_status.rb
|
219
|
+
- lib/pwinty/api_models/order_status_auth_details.rb
|
220
|
+
- lib/pwinty/api_models/order_status_details.rb
|
221
|
+
- lib/pwinty/api_models/order_status_issue.rb
|
222
|
+
- lib/pwinty/api_models/order_tracking.rb
|
223
|
+
- lib/pwinty/api_models/product.rb
|
224
|
+
- lib/pwinty/api_models/product_dimensions.rb
|
225
|
+
- lib/pwinty/api_models/product_variant.rb
|
202
226
|
- lib/pwinty/base.rb
|
203
|
-
- lib/pwinty/country.rb
|
204
227
|
- lib/pwinty/http_errors.rb
|
205
|
-
- lib/pwinty/image.rb
|
206
|
-
- lib/pwinty/order.rb
|
207
|
-
- lib/pwinty/order_status.rb
|
208
|
-
- lib/pwinty/photo_status.rb
|
209
|
-
- lib/pwinty/shipment.rb
|
210
|
-
- lib/pwinty/shipping_info.rb
|
211
228
|
- lib/pwinty/version.rb
|
212
229
|
- pwinty.gemspec
|
213
230
|
homepage: https://github.com/tomharvey/pwinty3-rb
|
@@ -216,7 +233,7 @@ licenses:
|
|
216
233
|
metadata:
|
217
234
|
homepage_uri: https://github.com/tomharvey/pwinty3-rb
|
218
235
|
source_code_uri: https://github.com/tomharvey/pwinty3-rb
|
219
|
-
documentation_uri: https://
|
236
|
+
documentation_uri: https://www.prodigi.com/print-api/docs/
|
220
237
|
post_install_message:
|
221
238
|
rdoc_options: []
|
222
239
|
require_paths:
|
@@ -232,8 +249,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
249
|
- !ruby/object:Gem::Version
|
233
250
|
version: '0'
|
234
251
|
requirements: []
|
235
|
-
rubygems_version: 3.
|
252
|
+
rubygems_version: 3.3.7
|
236
253
|
signing_key:
|
237
254
|
specification_version: 4
|
238
|
-
summary: Order photo prints through Pwinty
|
255
|
+
summary: Order photo prints through the Prodigi Pwinty API
|
239
256
|
test_files: []
|
data/lib/pwinty/country.rb
DELETED
data/lib/pwinty/image.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Pwinty
|
2
|
-
|
3
|
-
class Image < Pwinty::Base
|
4
|
-
attribute :id, Types::Integer
|
5
|
-
attribute :url, Types::String
|
6
|
-
attribute :status, Types::String
|
7
|
-
attribute :copies, Types::Integer
|
8
|
-
attribute :sizing, Types::String
|
9
|
-
attribute :price, Types::Integer
|
10
|
-
attribute :priceToUser, Types::Integer.optional
|
11
|
-
attribute :md5Hash, Types::String.optional
|
12
|
-
attribute :previewUrl, Types::String.optional
|
13
|
-
attribute :thumbnailUrl, Types::String.optional
|
14
|
-
attribute :sku, Types::String
|
15
|
-
attribute :attributes, Types::Hash.schema(
|
16
|
-
substrateWeight?: Types::String.optional,
|
17
|
-
frame?: Types::String.optional,
|
18
|
-
edge?: Types::String.optional,
|
19
|
-
paperType?: Types::String.optional,
|
20
|
-
frameColour?: Types::String.optional,
|
21
|
-
).optional
|
22
|
-
attribute :errorMessage, Types::String.optional
|
23
|
-
end
|
24
|
-
end
|
data/lib/pwinty/order.rb
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
require 'dry/struct/with_setters'
|
2
|
-
|
3
|
-
require "pwinty/shipping_info"
|
4
|
-
|
5
|
-
module Pwinty
|
6
|
-
class Order < Pwinty::Base
|
7
|
-
include Dry::Struct::Setters
|
8
|
-
include Dry::Struct::Setters::MassAssignment
|
9
|
-
|
10
|
-
attribute :id, Types::Integer
|
11
|
-
attribute :address1, Types::String.optional
|
12
|
-
attribute :address2, Types::String.optional
|
13
|
-
attribute :postalOrZipCode, Types::String.optional
|
14
|
-
attribute :countryCode, Types::String
|
15
|
-
attribute :addressTownOrCity, Types::String.optional
|
16
|
-
attribute :recipientName, Types::String.optional
|
17
|
-
attribute :stateOrCounty, Types::String.optional
|
18
|
-
attribute :status, Types::String
|
19
|
-
attribute :payment, Types::String
|
20
|
-
attribute? :packingSlipUrl, Types::String.optional
|
21
|
-
attribute :paymentUrl, Types::String.optional
|
22
|
-
attribute :price, Types::Integer
|
23
|
-
attribute :shippingInfo, Pwinty::ShippingInfo
|
24
|
-
attribute :images, Types::Array.of(Pwinty::Image)
|
25
|
-
attribute :merchantOrderId, Types::String.optional
|
26
|
-
attribute :preferredShippingMethod, Types::String
|
27
|
-
attribute :mobileTelephone, Types::String.optional
|
28
|
-
attribute :created, Types::JSON::DateTime
|
29
|
-
attribute :lastUpdated, Types::JSON::DateTime
|
30
|
-
attribute :canCancel, Types::Bool
|
31
|
-
attribute :canHold, Types::Bool
|
32
|
-
attribute :canUpdateShipping, Types::Bool
|
33
|
-
attribute :canUpdateImages, Types::Bool
|
34
|
-
attribute :errorMessage, Types::String.optional
|
35
|
-
attribute :invoiceAmountNet, Types::Integer
|
36
|
-
attribute :invoiceTax, Types::Integer
|
37
|
-
attribute :invoiceCurrency, Types::String.optional
|
38
|
-
attribute :tag, Types::String.optional
|
39
|
-
|
40
|
-
def self.list(page_size=50)
|
41
|
-
all_orders = list_each_page(page_size)
|
42
|
-
Pwinty.collate_results(all_orders, self)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.list_each_page(page_size, page_start=0, total_orders_count=nil)
|
46
|
-
all_orders = []
|
47
|
-
while total_orders_count.nil? or all_orders.count < total_orders_count
|
48
|
-
response = Pwinty.conn.get("orders?limit=#{page_size}&start=#{page_start}")
|
49
|
-
total_orders_count ||= response.body['data']['count']
|
50
|
-
all_orders = all_orders + response.body['data']['content']
|
51
|
-
page_start = page_start + page_size
|
52
|
-
end
|
53
|
-
all_orders
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def self.count
|
58
|
-
response = Pwinty.conn.get("orders?count=1&offset=0")
|
59
|
-
response.body['data']['count']
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def self.create(**args)
|
64
|
-
response = Pwinty.conn.post("orders", args)
|
65
|
-
new(response.body['data'])
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.find(id)
|
69
|
-
response = Pwinty.conn.get("orders/#{id}")
|
70
|
-
new(response.body['data'])
|
71
|
-
end
|
72
|
-
|
73
|
-
def update(**args)
|
74
|
-
update_body = self.to_hash.merge(args)
|
75
|
-
response = Pwinty.conn.put("orders/#{self.id}/", update_body)
|
76
|
-
self.assign_attributes(response.body['data'])
|
77
|
-
end
|
78
|
-
|
79
|
-
def submission_status
|
80
|
-
response = Pwinty.conn.get("orders/#{id}/SubmissionStatus")
|
81
|
-
Pwinty::OrderStatus.new(response.body['data'])
|
82
|
-
end
|
83
|
-
|
84
|
-
def submit
|
85
|
-
self.update_status 'Submitted'
|
86
|
-
end
|
87
|
-
|
88
|
-
def cancel
|
89
|
-
self.update_status 'Cancelled'
|
90
|
-
end
|
91
|
-
|
92
|
-
def hold
|
93
|
-
self.update_status 'AwaitingPayment'
|
94
|
-
end
|
95
|
-
|
96
|
-
def add_image image
|
97
|
-
images = add_images([image])
|
98
|
-
self.images
|
99
|
-
end
|
100
|
-
|
101
|
-
def add_images images
|
102
|
-
response = Pwinty.conn.post("orders/#{self.id}/images/batch", images)
|
103
|
-
success = response.status == 200
|
104
|
-
unless success
|
105
|
-
Pwinty.logger.warn response.body['statusTxt']
|
106
|
-
end
|
107
|
-
if response.body['data'] && response.body['data']['items']
|
108
|
-
images = Pwinty.collate_results(response.body['data']['items'], Pwinty::Image)
|
109
|
-
self.images = self.images + images
|
110
|
-
end
|
111
|
-
self.images
|
112
|
-
end
|
113
|
-
|
114
|
-
protected
|
115
|
-
|
116
|
-
def update_status status
|
117
|
-
response = Pwinty.conn.post("orders/#{self.id}/status", {status: status})
|
118
|
-
success = response.status == 200
|
119
|
-
unless success
|
120
|
-
Pwinty.logger.warn response.body['statusTxt']
|
121
|
-
end
|
122
|
-
success
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
end
|
data/lib/pwinty/order_status.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'pwinty/photo_status'
|
2
|
-
|
3
|
-
module Pwinty
|
4
|
-
|
5
|
-
class OrderStatus < Pwinty::Base
|
6
|
-
attribute :id, Types::Coercible::Integer
|
7
|
-
attribute :isValid, Types::Bool
|
8
|
-
attribute :generalErrors, Types::Array.of(Types::String)
|
9
|
-
attribute :photos, Types::Array.of(Pwinty::PhotoStatus)
|
10
|
-
|
11
|
-
|
12
|
-
def self.check(id)
|
13
|
-
response = Pwinty.conn.get("orders/#{id}/SubmissionStatus")
|
14
|
-
new(response.body['data'])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/pwinty/photo_status.rb
DELETED
data/lib/pwinty/shipment.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Pwinty
|
2
|
-
|
3
|
-
class Shipment < Pwinty::Base
|
4
|
-
attribute :shipmentId, Types::String.optional
|
5
|
-
attribute :isTracked, Types::Bool
|
6
|
-
attribute :trackingNumber, Types::String.optional
|
7
|
-
attribute :trackingUrl, Types::String.optional
|
8
|
-
attribute :carrier, Types::String.optional
|
9
|
-
attribute :photoIds, Types::Array.of(Types::Integer)
|
10
|
-
attribute :earliestEstimatedArrivalDate, Types::JSON::DateTime
|
11
|
-
attribute :latestEstimatedArrivalDate, Types::JSON::DateTime
|
12
|
-
attribute :shippedOn, Types::JSON::DateTime.optional
|
13
|
-
end
|
14
|
-
end
|