pwinty 1.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +12 -5
- data/.rspec +3 -0
- data/.travis.yml +22 -4
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +97 -0
- data/LICENSE.txt +21 -0
- data/README.md +208 -60
- data/Rakefile +3 -8
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pwinty.rb +47 -73
- data/lib/pwinty/base.rb +12 -0
- data/lib/pwinty/country.rb +12 -0
- data/lib/pwinty/http_errors.rb +13 -0
- data/lib/pwinty/image.rb +24 -0
- data/lib/pwinty/order.rb +110 -0
- data/lib/pwinty/order_status.rb +17 -0
- data/lib/pwinty/photo_status.rb +8 -0
- data/lib/pwinty/shipment.rb +14 -0
- data/lib/pwinty/shipping_info.rb +9 -0
- data/lib/pwinty/version.rb +1 -1
- data/pwinty.gemspec +34 -19
- metadata +141 -35
- data/CHANGELOG.md +0 -10
- data/CONTRIBUTING.md +0 -18
- data/lib/multipart.rb +0 -76
- data/test/test_client.rb +0 -117
- data/test/test_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29741067383be8a72dc43996cefe7425f8dedda4e3f63d92e374361bb39cb2a9
|
4
|
+
data.tar.gz: aee51c0441e3688c3545b7d85ffedea3377410af055c40d7f42b6219827f85ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6134e5d706fa2b1cdbee88cdb45e1b52144dc5a665f8a3e4f883fc9e5359d254ef49cad30ede707b895b71d1e059a067dc6150764a09637b805334e56a3a4c30
|
7
|
+
data.tar.gz: 5fbe7c669c81e7ce01ac3a4bf288e9aa17b3591bee7ee9f09e2f2ddfde643bc8073ffc091276077b72360687e2aef06fb43be16a866ec412c238232f075ace1f
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
2
4
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
- 2.5.5
|
6
|
+
before_install: gem install bundler -v 1.17.3
|
7
|
+
before_script:
|
8
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
9
|
+
> ./cc-test-reporter
|
10
|
+
- chmod +x ./cc-test-reporter
|
11
|
+
- "./cc-test-reporter before-build"
|
12
|
+
script:
|
13
|
+
- bundle exec rspec
|
14
|
+
after_script:
|
15
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
16
|
+
deploy:
|
17
|
+
provider: rubygems
|
18
|
+
api_key:
|
19
|
+
secure: kJP6MUaAZIlcGd3WC/3Cky/Mn0AwszGciN7J4oYLbDcYRT1s4Ga4Z/Zy2c7tyDr58dOf5Vgi4NKfqy8LDrw4QkRXp16zYEmiGLGuj1fv6PBRlOCBufFxotytkSXdqEzohOiC4xb+uT2Y0S/MOoOUphSxMzxGZtCfsUQgBOH108ybDRpKHmYgkuh1FRHIoT6kkSBL6aEgstQ0NlgxDDET0wYmoQ6FIjDyom9+yH14lW7Tf5R1YwNmHlHC7Z5VWQcANtxIi2BmJfzOQXO5N22cnoJh39+c1UsLEWgATjYJ0haI9hhleS+BoC0iAaaofbZmQFtIdlNk42zlMjYo9luG+cEVPsIj/u/G5BStOspMKVxnJIKCSY+stmyKZiZfZGZA+NTC3p6kVWXzR2ECWDpjpc2X+9ZbLHHNGY5o+rU3QZfK3WjQePU29XMbGgcFhwWd/4KRX2ty/km90uizJT8MXjsvvzjfJKtF8WsKi1MPEioI3y1qmJC1q/H0H6IbvyS6e41jmt3hXg1W+V98NbuUQtP5TWqqJ8ZnHti9EuR5YJAHDIzinQc1tBttr14ipOipnwCxDanbuJtr9UYSRQ6Dihkb/JvzyDEJFco+HLhoELNsgQa4qJ2z84Mpu/l16xxz+Ta3t8ChodN8q6E99frNfsQ5bUwrUzluUtnmZFgnuus=
|
20
|
+
gem: pwinty
|
21
|
+
on:
|
22
|
+
tags: true
|
23
|
+
repo: tomharvey/pwinty3-rb
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at tom@alush.co.uk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pwinty (3.0.0)
|
5
|
+
dry-struct (~> 1.0)
|
6
|
+
dry-struct-setters (~> 0.2)
|
7
|
+
faraday (~> 0.15)
|
8
|
+
faraday_middleware (~> 0.13)
|
9
|
+
json (~> 2.2)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
addressable (2.6.0)
|
15
|
+
public_suffix (>= 2.0.2, < 4.0)
|
16
|
+
concurrent-ruby (1.1.5)
|
17
|
+
crack (0.4.3)
|
18
|
+
safe_yaml (~> 1.0.0)
|
19
|
+
diff-lcs (1.3)
|
20
|
+
docile (1.3.2)
|
21
|
+
dry-configurable (0.8.3)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
dry-core (~> 0.4, >= 0.4.7)
|
24
|
+
dry-container (0.7.2)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
27
|
+
dry-core (0.4.9)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
dry-equalizer (0.2.2)
|
30
|
+
dry-inflector (0.1.2)
|
31
|
+
dry-logic (1.0.3)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
dry-core (~> 0.2)
|
34
|
+
dry-equalizer (~> 0.2)
|
35
|
+
dry-struct (1.0.0)
|
36
|
+
dry-core (~> 0.4, >= 0.4.3)
|
37
|
+
dry-equalizer (~> 0.2)
|
38
|
+
dry-types (~> 1.0)
|
39
|
+
ice_nine (~> 0.11)
|
40
|
+
dry-struct-setters (0.2.0)
|
41
|
+
dry-struct (>= 0.5.0)
|
42
|
+
dry-types (1.1.1)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
dry-container (~> 0.3)
|
45
|
+
dry-core (~> 0.4, >= 0.4.4)
|
46
|
+
dry-equalizer (~> 0.2, >= 0.2.2)
|
47
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
48
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
49
|
+
faraday (0.15.4)
|
50
|
+
multipart-post (>= 1.2, < 3)
|
51
|
+
faraday_middleware (0.13.1)
|
52
|
+
faraday (>= 0.7.4, < 1.0)
|
53
|
+
hashdiff (1.0.0)
|
54
|
+
ice_nine (0.11.2)
|
55
|
+
json (2.2.0)
|
56
|
+
multipart-post (2.1.1)
|
57
|
+
public_suffix (3.1.1)
|
58
|
+
rake (10.5.0)
|
59
|
+
rspec (3.8.0)
|
60
|
+
rspec-core (~> 3.8.0)
|
61
|
+
rspec-expectations (~> 3.8.0)
|
62
|
+
rspec-mocks (~> 3.8.0)
|
63
|
+
rspec-core (3.8.2)
|
64
|
+
rspec-support (~> 3.8.0)
|
65
|
+
rspec-expectations (3.8.4)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.8.0)
|
68
|
+
rspec-mocks (3.8.1)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.8.0)
|
71
|
+
rspec-support (3.8.2)
|
72
|
+
safe_yaml (1.0.5)
|
73
|
+
simplecov (0.17.0)
|
74
|
+
docile (~> 1.1)
|
75
|
+
json (>= 1.8, < 3)
|
76
|
+
simplecov-html (~> 0.10.0)
|
77
|
+
simplecov-html (0.10.2)
|
78
|
+
vcr (5.0.0)
|
79
|
+
webmock (3.6.2)
|
80
|
+
addressable (>= 2.3.6)
|
81
|
+
crack (>= 0.3.2)
|
82
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
ruby
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
bundler (~> 1.17)
|
89
|
+
pwinty!
|
90
|
+
rake (~> 10.0)
|
91
|
+
rspec (~> 3.0)
|
92
|
+
simplecov (~> 0.17)
|
93
|
+
vcr (~> 5.0)
|
94
|
+
webmock (~> 3.6)
|
95
|
+
|
96
|
+
BUNDLED WITH
|
97
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Thomas Harvey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,88 +1,236 @@
|
|
1
|
-
# Pwinty
|
1
|
+
# Pwinty
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/tomharvey/pwinty3-rb.svg?branch=master)](https://travis-ci.org/tomharvey/pwinty3-rb)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/pwinty3.svg)](https://badge.fury.io/rb/pwinty3)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/e92699eebe92f2db5758/test_coverage)](https://codeclimate.com/github/tomharvey/pwinty3-rb/test_coverage)
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/e92699eebe92f2db5758/maintainability)](https://codeclimate.com/github/tomharvey/pwinty3-rb/maintainability)
|
7
|
+
[![Known Vulnerabilities](https://snyk.io//test/github/tomharvey/pwinty3-rb/badge.svg?targetFile=Gemfile.lock)](https://snyk.io//test/github/tomharvey/pwinty3-rb?targetFile=Gemfile.lock)
|
4
8
|
|
5
|
-
While I consider this to be feature complete (it's the only Ruby Pwinty client that can `POST` photos as well as send photo URLs), I do want to hear if there are issues.
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
This wraps the Pwinty API at version 3 and aims to make your ruby life easier
|
11
|
+
when interacting with the API.
|
9
12
|
|
10
|
-
|
13
|
+
See http://pwinty.com and https://pwinty.com/api for more details around the
|
14
|
+
core service.
|
11
15
|
|
12
|
-
|
13
|
-
ENV['PWINTY_API_KEY'] = 'xxxxxxx'
|
14
|
-
@client = Pwinty.client
|
16
|
+
## Installation
|
15
17
|
|
16
|
-
|
18
|
+
Add this line to your application's Gemfile:
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
addressTownOrCity: "San Francisco",
|
22
|
-
stateOrCounty: "CA",
|
23
|
-
postalOrZipCode: "94101",
|
24
|
-
countryCode: "US",
|
25
|
-
payment: "InvoiceMe",
|
26
|
-
qualityLevel: "Standard"
|
27
|
-
)
|
20
|
+
``` ruby
|
21
|
+
gem 'pwinty'
|
22
|
+
```
|
28
23
|
|
29
|
-
|
24
|
+
And then execute:
|
30
25
|
|
31
|
-
|
32
|
-
orderId: order['id'],
|
33
|
-
type: "4x6",
|
34
|
-
url: "http://i.imgur.com/xXnrL.jpg",
|
35
|
-
copies: 1,
|
36
|
-
sizing: "Crop"
|
37
|
-
)
|
26
|
+
$ bundle
|
38
27
|
|
39
|
-
|
28
|
+
Or install it yourself as:
|
40
29
|
|
41
|
-
|
42
|
-
if !order_status['isValid']
|
43
|
-
puts "Invalid Order"
|
44
|
-
end
|
30
|
+
$ gem install pwinty
|
45
31
|
|
46
|
-
|
32
|
+
And include in your app with `require "pwinty"`
|
47
33
|
|
48
|
-
|
34
|
+
## Configuration
|
35
|
+
You can use environment variables or you can declare the configuration in your
|
36
|
+
app.
|
49
37
|
|
38
|
+
#### Authentication
|
39
|
+
To authenticate requests you must get your merchant ID and API Key from the
|
40
|
+
[Integration Settings in the Pwinty Dashboard](https://beta-dashboard.pwinty.com/settings/integrations).
|
50
41
|
|
51
|
-
|
42
|
+
These values must be set as the Environment Variables
|
43
|
+
`PWINTY_MERCHANT_ID` and `PWINTY_API_KEY`
|
44
|
+
or declared in your app using:
|
52
45
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
``` ruby
|
47
|
+
Pwinty::MERCHANT_ID = 'your merchant id'
|
48
|
+
Pwinty::API_KEY = 'your api key'
|
49
|
+
```
|
57
50
|
|
58
|
-
|
51
|
+
#### Production vs Sandbox
|
52
|
+
The Pwinty API provides a sandbox endpoint to test and develop against at
|
53
|
+
`https://sandbox.pwinty.com`. This is the default
|
54
|
+
endpoint used by this library.
|
59
55
|
|
60
|
-
|
61
|
-
|
56
|
+
When you are ready to switch to the production endpoint, set the
|
57
|
+
Environment Variable `PWINTY_BASE_URL` or declare the
|
58
|
+
constant in your app:
|
62
59
|
|
63
|
-
```
|
64
|
-
|
60
|
+
``` ruby
|
61
|
+
Pwinty::BASE_URL = 'https://api.pwinty.com' # Without a trailing slash
|
65
62
|
```
|
66
|
-
or add the following line to Gemfile:
|
67
63
|
|
68
|
-
|
69
|
-
|
64
|
+
## Usage
|
65
|
+
|
66
|
+
### Create an Order
|
67
|
+
|
68
|
+
These are the minimum variables you need to send to the API to register your
|
69
|
+
order, you'll want to add more or update later.
|
70
|
+
|
71
|
+
See the `lib/pwinty/order.rb` file or the
|
72
|
+
[API documentation](https://pwinty.com/api/#orders-create)
|
73
|
+
to understand the full list of attributes to send.
|
74
|
+
|
75
|
+
``` ruby
|
76
|
+
order = Pwinty::Order.create(
|
77
|
+
recipientName: "FirstName LastName",
|
78
|
+
countryCode: "US",
|
79
|
+
preferredShippingMethod: "Budget"
|
80
|
+
)
|
70
81
|
```
|
71
|
-
and run `bundle install` from your shell.
|
72
82
|
|
73
|
-
|
74
|
-
|
83
|
+
This create method will return a `Pwinty::Order` object.
|
84
|
+
|
85
|
+
### Get an existing Order from the API
|
86
|
+
|
87
|
+
Once an order is created you can retreive it from the API to further manage it,
|
88
|
+
or if it has been submitted you can see the latest production and shipping details.
|
89
|
+
|
90
|
+
``` ruby
|
91
|
+
order = Pwinty::Order.find(1) # Pass the ID returned when you created the Order
|
92
|
+
```
|
93
|
+
|
94
|
+
This method will return a `Pwinty::Order` object.
|
95
|
+
|
96
|
+
### Update an Order
|
97
|
+
|
98
|
+
Using the `order` object created in the above, we can update this using:
|
99
|
+
|
100
|
+
``` ruby
|
101
|
+
order.update(
|
102
|
+
address1: 'Street Name',
|
103
|
+
)
|
104
|
+
```
|
105
|
+
|
106
|
+
This update method will update the `Pwinty::Order` object.
|
107
|
+
|
108
|
+
### Validate an Order
|
109
|
+
|
110
|
+
Before submitting you might want to validate the order and check all is well.
|
111
|
+
|
112
|
+
``` ruby
|
113
|
+
status = order.submission_status
|
114
|
+
```
|
115
|
+
|
116
|
+
This will return a `Pwinty::OrderStatus` object. See the
|
117
|
+
[API documentation](https://pwinty.com/api/#orders-validate)
|
118
|
+
for more details of the shape of this reponse. But, you'll at least want the
|
119
|
+
`status.isValid` method for a boolean
|
120
|
+
check to see if it can be submitted.
|
121
|
+
|
122
|
+
### Add an Image to your Order
|
123
|
+
|
124
|
+
Add a single image by passing a hash to:
|
125
|
+
|
126
|
+
``` ruby
|
127
|
+
order.add_image(
|
128
|
+
sku: "GLOBAL-PHO-4X6-PRO",
|
129
|
+
url: "http://example.com/mytestphoto.jpg",
|
130
|
+
copies: 1,
|
131
|
+
)
|
132
|
+
```
|
133
|
+
|
134
|
+
or you can add multiple images by passing a list of hashes to the pluralised method:
|
135
|
+
|
136
|
+
``` ruby
|
137
|
+
order.add_images([
|
138
|
+
{
|
139
|
+
sku: "GLOBAL-PHO-4X6-PRO",
|
140
|
+
url: "http://example.com/myTestPhoto.jpg",
|
141
|
+
copies: 1,
|
142
|
+
}, {
|
143
|
+
sku: "GLOBAL-PHO-10X12-PRO",
|
144
|
+
url: "http://example.com/myLargeTestPhoto.jpg",
|
145
|
+
copies: 1,
|
146
|
+
}
|
147
|
+
])
|
148
|
+
```
|
149
|
+
|
150
|
+
On completion there will be a list of `Pwinty::Image` objects associated with `order.images`
|
151
|
+
|
152
|
+
|
153
|
+
### Submit, Cancel or Hold an order
|
154
|
+
|
155
|
+
Before you submit you should run Validate and ensure there are no errors.
|
156
|
+
|
157
|
+
``` ruby
|
158
|
+
order.submit
|
159
|
+
>>> true
|
160
|
+
|
161
|
+
order.cancel
|
162
|
+
>>> true
|
163
|
+
|
164
|
+
order.hold
|
165
|
+
>>> true
|
166
|
+
```
|
167
|
+
|
168
|
+
These methods will either submit your order for processing, or cancel/hold the
|
169
|
+
processing. Each will return a boolean.
|
170
|
+
|
171
|
+
### Check the shipment status of a submitted Order
|
172
|
+
|
173
|
+
Once created you can use the `find` method to get the most up to date info about an Order.
|
174
|
+
Following submission, this will contain a shippingInfo with a price for shipping and
|
175
|
+
a list of `Pwinty::Shipment` objects
|
176
|
+
|
177
|
+
``` ruby
|
178
|
+
order = Pwinty::Order.find(1)
|
179
|
+
order.shippingInfo.price
|
180
|
+
>>> 500
|
181
|
+
|
182
|
+
order.shippingInfo.shipments[0]
|
183
|
+
>>> #<Pwinty::Shipment shipmentId="1" isTracked=true trackingNumber="XYZ123456ABC" ...
|
184
|
+
```
|
185
|
+
|
186
|
+
### List your orders
|
187
|
+
|
188
|
+
``` ruby
|
189
|
+
orders = Pwinty::Order.list
|
190
|
+
```
|
191
|
+
**N.B - There appears to be an issue with the pagination of the list results from the API.
|
192
|
+
So you can only get the latest 100 results at this moment.**
|
193
|
+
|
194
|
+
Will return an array of `Pwinty::Order` objects.
|
195
|
+
|
196
|
+
### Count your orders
|
197
|
+
|
198
|
+
``` ruby
|
199
|
+
count = Pwinty::Order.count
|
200
|
+
```
|
201
|
+
Will return an integer of the number of orders you have.
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
## Development
|
206
|
+
|
207
|
+
After checking out the repo, run `bundle` to install dependencies. Then, run
|
208
|
+
`rake` to run the tests. You can also run `bin/console` for an interactive
|
209
|
+
prompt that will allow you to experiment.
|
210
|
+
|
211
|
+
The tests use VCRs to mock the responses from Pwinty's API.
|
212
|
+
|
213
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
214
|
+
To release a new version, update the version number in `version.rb`, and then
|
215
|
+
run `bundle exec rake release`, which will create a git tag for the version,
|
216
|
+
push git commits and tags, and push the `.gem` file to
|
217
|
+
[rubygems.org](https://rubygems.org).
|
218
|
+
|
219
|
+
## Contributing
|
75
220
|
|
76
|
-
|
221
|
+
Bug reports and pull requests are welcome on GitHub at
|
222
|
+
https://github.com/tomharvey/pwinty3-rb/issues. This project is intended to be
|
223
|
+
a safe, welcoming space for collaboration, and contributors are expected to
|
224
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org)
|
225
|
+
code of conduct.
|
77
226
|
|
78
|
-
License
|
79
|
-
-------
|
227
|
+
## License
|
80
228
|
|
81
|
-
|
229
|
+
The gem is available as open source under the terms of the
|
230
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
82
231
|
|
83
|
-
|
84
|
-
----------------
|
232
|
+
## Code of Conduct
|
85
233
|
|
86
|
-
|
87
|
-
|
88
|
-
|
234
|
+
Everyone interacting in the Pwinty project’s codebases, issue trackers, chat
|
235
|
+
rooms and mailing lists is expected to follow the
|
236
|
+
[code of conduct](https://github.com/tomharvey/pwinty3-rb/blob/master/CODE_OF_CONDUCT.md).
|