privateer 0.0.1
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 +15 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +13 -0
- data/lib/privateer.rb +6 -0
- data/lib/privateer/connection.rb +38 -0
- data/lib/privateer/version.rb +3 -0
- data/privateer.gemspec +28 -0
- data/spec/connection_spec.rb +72 -0
- data/spec/spec_helper.rb +20 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTUzNmNlODIwNDZiYmNhYmFlMjk3MmU4YzBlYjNiMjc5ODJlZWZjNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTE3ZTMyNWE2NTY2M2QwNzdkMjZiOGZlYTI1N2VmYjMxMDkyODEzZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTRkN2NlYTE3NDgyMmY2YWNlM2FlNzcwNjU0NjFmYTY3NDliOGM4YTQyODEw
|
10
|
+
ODJmODQxMGMyM2FhMmUyYjc5MWZlYjc5NzA4YTAzYmE3ZmExN2Y2MDI2MGFi
|
11
|
+
ZTM5ZjFmYTMxYWJiMDBiNmRkM2FhNWZlNDAxMzIzZDE2OTlkYWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzAwNGMyMzFlYmZhZTFiZGM1MjFjNGViNzIwYzhmZmM0OTJmMWNiMGRhY2I5
|
14
|
+
ZGU3ZmM1YWJlZGFhMzI2MjA5ZGJkNTA4ZWIwNTM4OWI1NDE5NWZkZmRkN2Y5
|
15
|
+
ODRkYTkxZmM4NGE1OGExZGI4YjZhODRjMjZhNTVhOWQ3ODNiNzE=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 James Thompson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Privateer
|
2
|
+
|
3
|
+
Privateer provides an interface for integrating private apps with the Shopify API.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/plainprogrammer/privateer)
|
6
|
+
[](https://codeclimate.com/github/plainprogrammer/privateer)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'privateer'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install privateer
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
store = Privateer::Connection.new(store_name: 'test', api_key: 'testkey', password: 'secret')
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/privateer.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Privateer::Connection
|
2
|
+
def initialize(options = {})
|
3
|
+
raise ArgumentError, 'store_name is required' if options[:store_name].nil?
|
4
|
+
raise ArgumentError, 'api_key is required' if options[:api_key].nil?
|
5
|
+
raise ArgumentError, 'password is required' if options[:password].nil?
|
6
|
+
|
7
|
+
@store_name = options[:store_name]
|
8
|
+
@api_key = options[:api_key]
|
9
|
+
@password = options[:password]
|
10
|
+
|
11
|
+
@store_url = "https://#{@api_key}:#{@password}@#{@store_name}.myshopify.com/admin/"
|
12
|
+
|
13
|
+
@connection = Faraday.new(url: @store_url)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(target, params = {})
|
17
|
+
call(:get, target, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def post(target, params = {})
|
21
|
+
call(:post, target, params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def put(target, params = {})
|
25
|
+
call(:put, target, params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def delete(target, params = {})
|
29
|
+
call(:delete, target, params)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def call(verb, target, params)
|
34
|
+
target += '.json' unless target =~ /\.json$/
|
35
|
+
resp = @connection.send(verb, target, params)
|
36
|
+
return resp.status, JSON.parse(resp.body), resp
|
37
|
+
end
|
38
|
+
end
|
data/privateer.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'privateer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'privateer'
|
8
|
+
spec.version = Privateer::VERSION
|
9
|
+
spec.authors = ['James Thompson']
|
10
|
+
spec.email = ['james@plainprograms.com']
|
11
|
+
spec.description = %q{A library for writing private apps for Shopify}
|
12
|
+
spec.summary = %q{Privateer provides an interface for integrating private apps with the Shopify API.}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'faraday', '~> 0.8.7'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 4.7.4'
|
26
|
+
spec.add_development_dependency 'turn', '~> 0.9.6'
|
27
|
+
spec.add_development_dependency 'vcr', '~> 2.4.0'
|
28
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Privateer::Connection do
|
4
|
+
let(:connection) { Privateer::Connection.new(VALID_OPTIONS) }
|
5
|
+
|
6
|
+
describe '.new' do
|
7
|
+
it 'accepts valid options' do
|
8
|
+
connection.must_be_instance_of Privateer::Connection
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'raises ArgumentError on missing store_name' do
|
12
|
+
lambda {
|
13
|
+
Privateer::Connection.new(api_key: 'testkey', password: 'secret')
|
14
|
+
}.must_raise ArgumentError
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'raises ArgumentError on missing api_key' do
|
18
|
+
lambda {
|
19
|
+
Privateer::Connection.new(store_name: 'test', password: 'secret')
|
20
|
+
}.must_raise ArgumentError
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'raises ArgumentError on missing password' do
|
24
|
+
lambda {
|
25
|
+
Privateer::Connection.new(store_name: 'test', api_key: 'testkey')
|
26
|
+
}.must_raise ArgumentError
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#get' do
|
31
|
+
it 'raises Argument Error on missing target' do
|
32
|
+
lambda {
|
33
|
+
connection.get
|
34
|
+
}.must_raise ArgumentError
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'accepts parameters' do
|
38
|
+
connection.get('products', {collection_id: 1})
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns a valid response' do
|
42
|
+
code, body, resp = connection.get('products')
|
43
|
+
code.must_equal 200
|
44
|
+
body.wont_be_nil
|
45
|
+
resp.must_be_instance_of Faraday::Response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#post' do
|
50
|
+
it 'raises Argument Error on missing target' do
|
51
|
+
lambda {
|
52
|
+
connection.post
|
53
|
+
}.must_raise ArgumentError
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#put' do
|
58
|
+
it 'raises Argument Error on missing target' do
|
59
|
+
lambda {
|
60
|
+
connection.put
|
61
|
+
}.must_raise ArgumentError
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#delete' do
|
66
|
+
it 'raises Argument Error on missing target' do
|
67
|
+
lambda {
|
68
|
+
connection.delete
|
69
|
+
}.must_raise ArgumentError
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'minitest/spec'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'turn'
|
7
|
+
|
8
|
+
require 'privateer'
|
9
|
+
|
10
|
+
Turn.config do |c|
|
11
|
+
c.format = :outline
|
12
|
+
c.trace = true
|
13
|
+
c.natural = true
|
14
|
+
end
|
15
|
+
|
16
|
+
VALID_OPTIONS = {
|
17
|
+
store_name: ENV['SHOPIFY_TEST_STORE'] || 'test',
|
18
|
+
api_key: ENV['SHOPIFY_TEST_API_KEY'] || 'test',
|
19
|
+
password: ENV['SHOPIFY_TEST_PASSWORD'] || 'test',
|
20
|
+
}
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: privateer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Thompson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.7.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.7.4
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: turn
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.6
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.6
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.4.0
|
97
|
+
description: A library for writing private apps for Shopify
|
98
|
+
email:
|
99
|
+
- james@plainprograms.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/privateer.rb
|
110
|
+
- lib/privateer/connection.rb
|
111
|
+
- lib/privateer/version.rb
|
112
|
+
- privateer.gemspec
|
113
|
+
- spec/connection_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: ''
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.0.3
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Privateer provides an interface for integrating private apps with the Shopify
|
139
|
+
API.
|
140
|
+
test_files:
|
141
|
+
- spec/connection_spec.rb
|
142
|
+
- spec/spec_helper.rb
|