pwinty 1.0.1 → 1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +18 -0
- data/README.md +3 -0
- data/lib/pwinty.rb +15 -8
- data/lib/pwinty/version.rb +1 -1
- data/test/test_client.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba48de731456c5d3e1711ccb6948341e7be0f8a
|
4
|
+
data.tar.gz: 7961236e86238b56f33db744a1fceea1f9256e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a333e0985076382c190a99c6303359e4abeaa41cc85f478d9165b938b85d634d7dbe57ebf57390dd7315c847d80b31e9a483f697b0c396cd1b9b353e4c2c61
|
7
|
+
data.tar.gz: 174157a41d6818447e52bfaa2df9d917d2db388629f09d311e4d4e75e3433250563ba943cc96c4db6ddda8ab8b9742ad7d4b1b1aeb67e67b999f6cd9671fc2ac
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
## 1.1.0 (2016-12-26)
|
2
|
+
|
3
|
+
* Add support for adding photos in a batch (Thanks @bumi!)
|
4
|
+
* Support for configurable Pwinty API versions (Thanks @bumi!)
|
5
|
+
* Added support for passing client credentials as arguments instead of ENV variables (Thanks @bumi!)
|
6
|
+
|
7
|
+
|
8
|
+
## 1.0.1 (2015-04-10)
|
9
|
+
|
10
|
+
* Create a working Pwinty client with [rest-client](https://github.com/rest-client/rest-client)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/dereklucas/pwinty/pulls).
|
9
|
+
* Review open [issues](https://github.com/dereklucas/pwinty/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/dereklucas/pwinty/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `dereklucas/pwinty` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/dereklucas/pwinty/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/dereklucas/pwinty/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This library implements a Ruby client for the [Pwinty photo printing API](http://www.pwinty.com/Api).
|
4
4
|
|
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
|
+
|
5
7
|
Documentation
|
6
8
|
-------------
|
7
9
|
|
@@ -83,3 +85,4 @@ More Information
|
|
83
85
|
|
84
86
|
* [Rubygems](https://rubygems.org/gems/pwinty)
|
85
87
|
* [Issues](https://github.com/dereklucas/pwinty/issues)
|
88
|
+
* Follows [SemVer](http://semver.org)
|
data/lib/pwinty.rb
CHANGED
@@ -4,19 +4,22 @@ require "rest_client"
|
|
4
4
|
|
5
5
|
module Pwinty
|
6
6
|
|
7
|
-
def self.client
|
8
|
-
@@client ||= Pwinty::Client.new
|
7
|
+
def self.client(args={})
|
8
|
+
@@client ||= Pwinty::Client.new(args)
|
9
9
|
@@client
|
10
10
|
end
|
11
11
|
|
12
12
|
class Client
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
attr_accessor :pwinty
|
14
|
+
def initialize(args={})
|
15
|
+
options = { merchant_id: ENV['PWINTY_MERCHANT_ID'], api_key: ENV['PWINTY_API_KEY'], production: ENV['PWINTY_PRODUCTION'] == 'true' }.merge(args)
|
16
|
+
subdomain = options[:production] == true ? "api" : "sandbox"
|
17
|
+
apiVersion = options[:api_version] || 'v2.1'
|
18
|
+
domain = "https://#{subdomain}.pwinty.com/#{apiVersion}"
|
16
19
|
|
17
20
|
@pwinty = RestClient::Resource.new(domain, :headers => {
|
18
|
-
"X-Pwinty-MerchantId" =>
|
19
|
-
"X-Pwinty-REST-API-Key" =>
|
21
|
+
"X-Pwinty-MerchantId" => options[:merchant_id],
|
22
|
+
"X-Pwinty-REST-API-Key" => options[:api_key],
|
20
23
|
'Accept' => 'application/json'
|
21
24
|
})
|
22
25
|
end
|
@@ -68,7 +71,11 @@ module Pwinty
|
|
68
71
|
JSON.parse @pwinty["/Orders/#{orderId}/Photos"].post(args, headers)
|
69
72
|
end
|
70
73
|
|
71
|
-
|
74
|
+
def add_photos(orderId, photos)
|
75
|
+
body = photos.is_a?(String) ? photos : photos.to_json
|
76
|
+
JSON.parse @pwinty["/Orders/#{orderId}/Photos/Batch"].post(body, {'Content-Type' => 'application/json'} )
|
77
|
+
end
|
78
|
+
|
72
79
|
def delete_photo(orderId, photoId)
|
73
80
|
JSON.parse @pwinty["/Orders/#{orderId}/Photos/#{photoId}"].delete
|
74
81
|
end
|
data/lib/pwinty/version.rb
CHANGED
data/test/test_client.rb
CHANGED
@@ -14,7 +14,7 @@ class TestClient < Test::Unit::TestCase
|
|
14
14
|
qualityLevel: "Standard"
|
15
15
|
}
|
16
16
|
|
17
|
-
@client = Pwinty.client
|
17
|
+
@client = Pwinty.client(merchant_id: ENV['PWINTY_MERCHANT_ID'], api_key: ENV['PWINTY_API_KEY'], production: false)
|
18
18
|
|
19
19
|
@order_keys = %w[ id status price
|
20
20
|
address1 address2
|
@@ -42,6 +42,7 @@ class TestClient < Test::Unit::TestCase
|
|
42
42
|
assert_equal body["items"].class, Array
|
43
43
|
end
|
44
44
|
def test_get_orders_integration
|
45
|
+
# NOTE: works only if you already have an order created. the first ever test run will probably fail
|
45
46
|
body = @client.get_orders
|
46
47
|
assert_equal body.class, Array
|
47
48
|
assert_equal body.first.keys.sort!, @order_keys.sort!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwinty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -75,6 +75,8 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
77
|
- ".travis.yml"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- CONTRIBUTING.md
|
78
80
|
- Gemfile
|
79
81
|
- README.md
|
80
82
|
- Rakefile
|
@@ -104,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
106
|
version: '0'
|
105
107
|
requirements: []
|
106
108
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.6.6
|
108
110
|
signing_key:
|
109
111
|
specification_version: 4
|
110
112
|
summary: A Ruby client for the Pwinty API
|