woocommerce 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/woocommerce.rb +68 -0
- data/lib/woocommerce/version.rb +3 -0
- data/woocommerce.gemspec +27 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7d1a4dcc9a97d3447265b02cb5d5c0c781c08798
|
4
|
+
data.tar.gz: 81a437872c06925c025eb17ee8040d4e425ead96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1963230d405f73c3bf75192f11201af2f32bf8f0963ee0c8c9ae8f5333085ebf04020d8df7d02b8e0a8ed783bf1fd465c6c08423a29baa1f1f58576037571faa
|
7
|
+
data.tar.gz: 7c06ea7534a63eb36d7309c6ed1f53560a22874d8f9ef48ba8f9309b43d6dd19f92e2907205107fdd08db4cfacd66b3420dc139eed9a18f21b07812d20d6579e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Josh Dvir
|
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,31 @@
|
|
1
|
+
# Woocommerce
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'woocommerce'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install woocommerce
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/woocommerce/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/woocommerce.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "woocommerce/version"
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module Woocommerce
|
5
|
+
class API
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
# Default timeout of 3 seconds
|
9
|
+
DEFAULT_TIMEOUT = 3
|
10
|
+
|
11
|
+
API_ENDPOINT = '/wc-api/v2/'
|
12
|
+
|
13
|
+
# Default headers for HTTP requests
|
14
|
+
DEFAULT_HEADERS = {
|
15
|
+
'User-Agent' => "WooCommerce gem #{Woocommerce::VERSION}",
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
attr_accessor :consumer_key, :consumer_secret
|
20
|
+
|
21
|
+
format(:json)
|
22
|
+
headers(DEFAULT_HEADERS)
|
23
|
+
default_timeout(DEFAULT_TIMEOUT)
|
24
|
+
|
25
|
+
def initialize(consumer_key, consumer_secret, store_url)
|
26
|
+
if consumer_key and consumer_secret and store_url and store_url.start_with?('https')
|
27
|
+
@consumer_key = consumer_key
|
28
|
+
@consumer_secret = consumer_secret
|
29
|
+
self.class.base_uri store_url + API_ENDPOINT
|
30
|
+
self.class.default_params consumer_key: @consumer_key
|
31
|
+
self.class.default_params consumer_secret: @consumer_secret
|
32
|
+
else
|
33
|
+
raise 'We need all arguments, and store_url must start with https'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Turn on HTTParty debugging
|
38
|
+
#
|
39
|
+
# @param location [Object] Output "sink" for HTTP debugging
|
40
|
+
def debug(location = $stderr)
|
41
|
+
self.class.debug_output(location)
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_http_headers(http_headers = {})
|
45
|
+
http_headers.merge!(DEFAULT_HEADERS)
|
46
|
+
self.class.headers(http_headers)
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_timeout(timeout)
|
50
|
+
self.class.default_timeout(timeout)
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_products
|
54
|
+
endpoint = woocommerce_api_url_for('products')
|
55
|
+
self.class.get(endpoint).parsed_response
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_product(product_id)
|
59
|
+
endpoint = woocommerce_api_url_for("products/#{product_id}")
|
60
|
+
self.class.get(endpoint).parsed_response
|
61
|
+
end
|
62
|
+
|
63
|
+
def woocommerce_api_url_for(method)
|
64
|
+
"#{self.class.base_uri}/#{method}"
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/woocommerce.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'woocommerce/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "woocommerce"
|
8
|
+
spec.version = Woocommerce::VERSION
|
9
|
+
spec.authors = ["Josh Dvir"]
|
10
|
+
spec.email = ["shuky.dvir@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby WooCommerce client library}
|
12
|
+
spec.description = %q{Ruby WooCommerce client library}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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 'httparty'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "awesome_print"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: woocommerce
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Dvir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
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: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: awesome_print
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Ruby WooCommerce client library
|
84
|
+
email:
|
85
|
+
- shuky.dvir@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/woocommerce.rb
|
96
|
+
- lib/woocommerce/version.rb
|
97
|
+
- woocommerce.gemspec
|
98
|
+
homepage: ''
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.4.5
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Ruby WooCommerce client library
|
122
|
+
test_files: []
|