Skip to content

Commit accc42c

Browse files
committed
base from tradegecko/woocommerce_api
0 parents  commit accc42c

File tree

129 files changed

+8460
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+8460
-0
lines changed

Gemfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
source "https://rubygems.org"
2+
3+
gem "activesupport"
4+
gem "activemodel"
5+
gem "httparty"
6+
gem "virtus"
7+
8+
group :development do
9+
gem "bundler"
10+
gem "jeweler"
11+
gem "rdoc"
12+
gem "rspec"
13+
gem 'webmock'
14+
gem "vcr"
15+
gem "pry"
16+
end

Gemfile.lock

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activemodel (5.1.5)
5+
activesupport (= 5.1.5)
6+
activesupport (5.1.5)
7+
concurrent-ruby (~> 1.0, >= 1.0.2)
8+
i18n (~> 0.7)
9+
minitest (~> 5.1)
10+
tzinfo (~> 1.1)
11+
addressable (2.4.0)
12+
axiom-types (0.1.1)
13+
descendants_tracker (~> 0.0.4)
14+
ice_nine (~> 0.11.0)
15+
thread_safe (~> 0.3, >= 0.3.1)
16+
builder (3.2.3)
17+
coderay (1.1.2)
18+
coercible (1.0.0)
19+
descendants_tracker (~> 0.0.1)
20+
concurrent-ruby (1.0.5)
21+
crack (0.4.3)
22+
safe_yaml (~> 1.0.0)
23+
descendants_tracker (0.0.4)
24+
thread_safe (~> 0.3, >= 0.3.1)
25+
diff-lcs (1.3)
26+
equalizer (0.0.11)
27+
faraday (0.9.2)
28+
multipart-post (>= 1.2, < 3)
29+
git (1.3.0)
30+
github_api (0.16.0)
31+
addressable (~> 2.4.0)
32+
descendants_tracker (~> 0.0.4)
33+
faraday (~> 0.8, < 0.10)
34+
hashie (>= 3.4)
35+
mime-types (>= 1.16, < 3.0)
36+
oauth2 (~> 1.0)
37+
hashdiff (0.3.7)
38+
hashie (3.5.7)
39+
highline (1.7.10)
40+
httparty (0.16.0)
41+
multi_xml (>= 0.5.2)
42+
i18n (0.9.5)
43+
concurrent-ruby (~> 1.0)
44+
ice_nine (0.11.2)
45+
jeweler (2.3.9)
46+
builder
47+
bundler
48+
git (>= 1.2.5)
49+
github_api (~> 0.16.0)
50+
highline (>= 1.6.15)
51+
nokogiri (>= 1.5.10)
52+
psych
53+
rake
54+
rdoc
55+
semver2
56+
jwt (1.5.6)
57+
method_source (0.9.0)
58+
mime-types (2.99.3)
59+
mini_portile2 (2.4.0)
60+
minitest (5.11.3)
61+
multi_json (1.13.1)
62+
multi_xml (0.6.0)
63+
multipart-post (2.0.0)
64+
nokogiri (1.10.1)
65+
mini_portile2 (~> 2.4.0)
66+
oauth2 (1.4.0)
67+
faraday (>= 0.8, < 0.13)
68+
jwt (~> 1.0)
69+
multi_json (~> 1.3)
70+
multi_xml (~> 0.5)
71+
rack (>= 1.2, < 3)
72+
pry (0.11.3)
73+
coderay (~> 1.1.0)
74+
method_source (~> 0.9.0)
75+
psych (3.0.2)
76+
rack (2.0.6)
77+
rake (12.3.0)
78+
rdoc (6.0.1)
79+
rspec (3.7.0)
80+
rspec-core (~> 3.7.0)
81+
rspec-expectations (~> 3.7.0)
82+
rspec-mocks (~> 3.7.0)
83+
rspec-core (3.7.1)
84+
rspec-support (~> 3.7.0)
85+
rspec-expectations (3.7.0)
86+
diff-lcs (>= 1.2.0, < 2.0)
87+
rspec-support (~> 3.7.0)
88+
rspec-mocks (3.7.0)
89+
diff-lcs (>= 1.2.0, < 2.0)
90+
rspec-support (~> 3.7.0)
91+
rspec-support (3.7.1)
92+
safe_yaml (1.0.4)
93+
semver2 (3.4.2)
94+
thread_safe (0.3.6)
95+
tzinfo (1.2.5)
96+
thread_safe (~> 0.1)
97+
vcr (4.0.0)
98+
virtus (1.0.5)
99+
axiom-types (~> 0.1)
100+
coercible (~> 1.0)
101+
descendants_tracker (~> 0.0, >= 0.0.3)
102+
equalizer (~> 0.0, >= 0.0.9)
103+
webmock (3.3.0)
104+
addressable (>= 2.3.6)
105+
crack (>= 0.3.2)
106+
hashdiff
107+
108+
PLATFORMS
109+
ruby
110+
111+
DEPENDENCIES
112+
activemodel
113+
activesupport
114+
bundler
115+
httparty
116+
jeweler
117+
pry
118+
rdoc
119+
rspec
120+
vcr
121+
virtus
122+
webmock
123+
124+
BUNDLED WITH
125+
1.17.3

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Philip Mark Deazeta
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 all
13+
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 THE
21+
SOFTWARE.
22+

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Ruby Client for Woocommerce API
2+
3+
[![Build Status](https://semaphoreci.com/api/v1/tradegecko/woocommerce_api/branches/fix-variations/badge.svg)](https://semaphoreci.com/tradegecko/woocommerce_api)
4+
## Installation
5+
```ruby
6+
gem "woocommerce_api", github: "tradegecko/woocommerce_api"
7+
```
8+
```ruby
9+
require "woocommerce_api"
10+
```
11+
12+
## Initialize authorize access
13+
14+
```ruby
15+
# Through https
16+
WoocommerceAPI::Client.new(
17+
consumer_key: "ck_1234",
18+
consumer_secret: "cs_1234",
19+
store_url: "https://example.com")
20+
21+
# Through https but sending consumer_key and consumer_secret as query string
22+
WoocommerceAPI::Client.new(
23+
consumer_key: "ck_1234",
24+
consumer_secret: "cs_1234",
25+
store_url: "https://example.com",
26+
mode: :query_https)
27+
28+
# Through http (Oauth)
29+
WoocommerceAPI::Client.new(
30+
consumer_key: "ck_1234",
31+
consumer_secret: "cs_1234",
32+
store_url: "https://example.com",
33+
mode: :oauth_http)
34+
```
35+
36+
## Calling API
37+
### Collection endpoints
38+
returns a collection of the resource, size of collection limited by a configuration in Woocommerce setting (10 by default)
39+
```ruby
40+
WoocommerceAPI::Product.all
41+
=> [collection of products]
42+
```
43+
collection with parameters, check more http://woothemes.github.io/woocommerce-rest-api-docs/#parameters
44+
```ruby
45+
WoocommerceAPI::Product.all(filter: { limit: 50 })
46+
WoocommerceAPI::Order.all(filter: { status: "complete", created_at_min: "2015-11-01" })
47+
```
48+
### Count
49+
```ruby
50+
WoocommerceAPI::Product.count
51+
WoocommerceAPI::Order.count(filter: { status: "commplete" })
52+
```
53+
### Finding a resource
54+
```ruby
55+
WoocommerceAPI::Product.find(1)
56+
WoocommerceAPI::Order.find(1)
57+
```
58+
### Update a resource
59+
```ruby
60+
product = WoocommerceAPI::Product.find(1)
61+
product.update_attributes(regular_price: 100, managing_stock: true)
62+
# or
63+
product.regular_price = 100
64+
product.managing_stock = true
65+
product.save
66+
```
67+
### Destroy a resource
68+
```ruby
69+
product.destroy # Soft delete a product (move to trash)
70+
product.destroy(force: true) # Permanently delete a product
71+
```
72+
73+
## Debugging
74+
We are using HTTParty, then...
75+
```ruby
76+
WoocommerceAPI::OauthClient.debug_output $stdout
77+
WoocommerceAPI::Client.debug_output $stdout
78+
```

Rakefile

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# encoding: utf-8
2+
3+
require 'rubygems'
4+
require 'bundler'
5+
begin
6+
Bundler.setup(:default, :development)
7+
rescue Bundler::BundlerError => e
8+
$stderr.puts e.message
9+
$stderr.puts "Run `bundle install` to install missing gems"
10+
exit e.status_code
11+
end
12+
require 'rake'
13+
14+
require 'jeweler'
15+
Jeweler::Tasks.new do |gem|
16+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17+
gem.name = "woocommerce_api"
18+
gem.homepage = "http://github.com/tradegecko/woocommerce_api"
19+
gem.license = "MIT"
20+
gem.summary = %Q{Enables Ruby applications to communicate with the WooCommerce API}
21+
gem.description = %Q{Enables Ruby applications to communicate with the WooCommerce API.}
22+
gem.email = "[email protected]"
23+
gem.authors = ["TradeGecko"]
24+
# dependencies defined in Gemfile
25+
gem.files = Dir.glob('lib/**/*.rb')
26+
end
27+
Jeweler::RubygemsDotOrgTasks.new
28+
29+
require 'rake/testtask'
30+
Rake::TestTask.new(:test) do |test|
31+
test.libs << 'lib' << 'test'
32+
test.pattern = 'test/**/test_*.rb'
33+
test.verbose = true
34+
end
35+
36+
task :default => :test
37+
38+
require 'rdoc/task'
39+
Rake::RDocTask.new do |rdoc|
40+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
41+
42+
rdoc.rdoc_dir = 'rdoc'
43+
rdoc.title = "woocommerce_api #{version}"
44+
rdoc.rdoc_files.include('README*')
45+
rdoc.rdoc_files.include('lib/**/*.rb')
46+
end
47+
48+
desc "Open an irb session with WoocommerceAPI"
49+
task :console do
50+
require 'irb'
51+
require 'irb/completion'
52+
require 'woocommerce-api'
53+
ARGV.clear
54+
IRB.start
55+
end

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.0

0 commit comments

Comments
 (0)