kitely 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/kitely.gemspec +33 -0
- data/lib/kitely.rb +28 -0
- data/lib/kitely/customer.rb +12 -0
- data/lib/kitely/order.rb +34 -0
- data/lib/kitely/photobook.rb +28 -0
- data/lib/kitely/version.rb +3 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bfb7b0799eeba2bdc12ea81e2f0c15a21db5cc9a01c577ceb3bc1c4e0c076bb2
|
4
|
+
data.tar.gz: 2598250651818744e843c31f929c6306e80f99f41f24fa1476db1ce51227bae6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61b62f17698ed3d2ffc50aaa011beb128b931abdc98ab5bdb4defa60574166c3bca291fffef1b07dadd9359bb69345e3948710339be0dd1cdba1b8f530866ff1
|
7
|
+
data.tar.gz: 8b21dd1ccf2d6e53dde8d5de24f10388a4ed840488df49013ed293c95ff25342326415e2032116e22ba2fa8a5943985e9875904cd6e631b4885bda4bac8b81c9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
kitely (0.1.0)
|
5
|
+
http (~> 4.1.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.6.0)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
domain_name (0.5.20190701)
|
14
|
+
unf (>= 0.0.5, < 1.0.0)
|
15
|
+
http (4.1.1)
|
16
|
+
addressable (~> 2.3)
|
17
|
+
http-cookie (~> 1.0)
|
18
|
+
http-form_data (~> 2.0)
|
19
|
+
http_parser.rb (~> 0.6.0)
|
20
|
+
http-cookie (1.0.3)
|
21
|
+
domain_name (~> 0.5)
|
22
|
+
http-form_data (2.1.1)
|
23
|
+
http_parser.rb (0.6.0)
|
24
|
+
public_suffix (3.1.1)
|
25
|
+
rake (10.5.0)
|
26
|
+
rspec (3.8.0)
|
27
|
+
rspec-core (~> 3.8.0)
|
28
|
+
rspec-expectations (~> 3.8.0)
|
29
|
+
rspec-mocks (~> 3.8.0)
|
30
|
+
rspec-core (3.8.2)
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-expectations (3.8.4)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.8.0)
|
35
|
+
rspec-mocks (3.8.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.8.0)
|
38
|
+
rspec-support (3.8.2)
|
39
|
+
unf (0.1.4)
|
40
|
+
unf_ext
|
41
|
+
unf_ext (0.0.7.6)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler (~> 2.0)
|
48
|
+
kitely!
|
49
|
+
rake (~> 10.0)
|
50
|
+
rspec (~> 3.0)
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Michael Bumann
|
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
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Kitely
|
2
|
+
|
3
|
+
Ruby API wrapper for [kite.ly](https://www.kite.ly) - the print on demand service
|
4
|
+
|
5
|
+
|
6
|
+
This is a prototype, pull requests welcome.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'kitely'
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install kitely
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
|
24
|
+
Kitely.secret_key = 'xxxx'
|
25
|
+
Kitely.public_key = 'yyyy'
|
26
|
+
|
27
|
+
book = Kitely::Photobook.new
|
28
|
+
book.front_cover = 'https://s3.amazonaws.com/sdk-static/TestImages/1.png'
|
29
|
+
book.back_cover = 'https://s3.amazonaws.com/sdk-static/TestImages/1.png'
|
30
|
+
|
31
|
+
[].each do |photo_url|
|
32
|
+
book.add_page(photo_url)
|
33
|
+
end
|
34
|
+
|
35
|
+
customer = Kitely::Customer.new
|
36
|
+
customer.shipping_address = {recipient_name: 'Joe Kite'}
|
37
|
+
customer.phone = '+4917012345678'
|
38
|
+
customer.email = 'joe@example.com'
|
39
|
+
|
40
|
+
order = Kitely::Order.new(customer: customer)
|
41
|
+
oder.add(book)
|
42
|
+
|
43
|
+
response = order.order!
|
44
|
+
puts response.body.to_s
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kitely"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/kitely.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "kitely/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "kitely"
|
7
|
+
spec.version = Kitely::VERSION
|
8
|
+
spec.authors = ["Michael Bumann"]
|
9
|
+
spec.email = ["hello@michaelbumann.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Ruby API wrapper for the kite.ly API}
|
12
|
+
spec.description = %q{API wrapper to the print on demand service kite.ly"}
|
13
|
+
spec.homepage = "https://github.com/bumi/kite.ly"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "http", "~>4.1.1"
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
end
|
data/lib/kitely.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "kitely/version"
|
2
|
+
|
3
|
+
require 'kitely/customer'
|
4
|
+
require 'kitely/order'
|
5
|
+
require 'kitely/photobook'
|
6
|
+
|
7
|
+
module Kitely
|
8
|
+
class Error < StandardError; end
|
9
|
+
BASE_URL = 'https://api.kite.ly/v4.0/'
|
10
|
+
|
11
|
+
def self.secret_key=(key)
|
12
|
+
@secret_key = key
|
13
|
+
end
|
14
|
+
def self.secret_key
|
15
|
+
@secret_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.public_key=(key)
|
19
|
+
@public_key = key
|
20
|
+
end
|
21
|
+
def self.public_key
|
22
|
+
@public_key
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.url(path)
|
26
|
+
"#{BASE_URL}#{path}"
|
27
|
+
end
|
28
|
+
end
|
data/lib/kitely/order.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'http'
|
2
|
+
module Kitely
|
3
|
+
class Order
|
4
|
+
|
5
|
+
attr_accessor :jobs, :customer
|
6
|
+
|
7
|
+
def initialize(customer:)
|
8
|
+
self.customer = customer
|
9
|
+
self.jobs = []
|
10
|
+
yield jobs if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def add(job)
|
14
|
+
self.jobs.push(job)
|
15
|
+
end
|
16
|
+
|
17
|
+
def attributes
|
18
|
+
{
|
19
|
+
shipping_address: self.customer.shipping_address,
|
20
|
+
customer_phone: self.customer.phone,
|
21
|
+
customer_email: self.customer.email,
|
22
|
+
jobs: self.jobs.map(&:attributes)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def order!
|
27
|
+
self.http.post(Kitely.url('print'), json: self.attributes)
|
28
|
+
end
|
29
|
+
|
30
|
+
def http
|
31
|
+
@http ||= HTTP.auth("ApiKey #{Kitely.public_key}:#{Kitely.secret_key}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Kitely
|
2
|
+
class Photobook
|
3
|
+
attr_accessor :template_id, :front_cover, :back_cover, :pages
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
self.template_id = options[:template] || 'photobook_wrap_21x21_square'
|
7
|
+
self.pages = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_page(page)
|
11
|
+
if page.is_a?(String)
|
12
|
+
page = { asset: page }
|
13
|
+
end
|
14
|
+
self.pages << { layout: 'single_centered' }.merge(page)
|
15
|
+
end
|
16
|
+
|
17
|
+
def attributes
|
18
|
+
{
|
19
|
+
template_id: self.template_id,
|
20
|
+
assets: {
|
21
|
+
front_cover: self.front_cover,
|
22
|
+
back_cover: self.back_cover,
|
23
|
+
pages: self.pages
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kitely
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Bumann
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: API wrapper to the print on demand service kite.ly"
|
70
|
+
email:
|
71
|
+
- hello@michaelbumann.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- kitely.gemspec
|
87
|
+
- lib/kitely.rb
|
88
|
+
- lib/kitely/customer.rb
|
89
|
+
- lib/kitely/order.rb
|
90
|
+
- lib/kitely/photobook.rb
|
91
|
+
- lib/kitely/version.rb
|
92
|
+
homepage: https://github.com/bumi/kite.ly
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata:
|
96
|
+
homepage_uri: https://github.com/bumi/kite.ly
|
97
|
+
source_code_uri: https://github.com/bumi/kite.ly
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubygems_version: 3.0.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Ruby API wrapper for the kite.ly API
|
117
|
+
test_files: []
|