spree-api-client 0.0.1 → 0.2.3
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/CHANGELOG.md +9 -0
- data/LICENSE.txt +674 -0
- data/README.md +31 -38
- data/lib/spree_client.rb +3 -0
- data/lib/spree_client.rb~ +71 -0
- data/lib/spree_client/api.rb +1 -0
- data/lib/spree_client/api/v1.rb +53 -0
- data/lib/spree_client/api/v1/products.rb +23 -0
- data/lib/spree_client/api/v1/properties.rb +12 -0
- data/lib/spree_client/api/v1/resources.rb +142 -0
- data/lib/spree_client/api/v1/stock_items.rb +27 -0
- data/lib/spree_client/api/v1/stock_locations.rb +33 -0
- data/lib/spree_client/api/v1/stock_movements.rb +16 -0
- data/lib/spree_client/api/v1/taxonomies.rb +12 -0
- data/lib/spree_client/api/v1/variants.rb +13 -0
- data/lib/spree_client/attributes.rb +27 -0
- data/lib/spree_client/models.rb +5 -0
- data/lib/spree_client/models/product.rb +7 -0
- data/lib/spree_client/models/property.rb +6 -0
- data/lib/spree_client/models/stock_item.rb +7 -0
- data/lib/spree_client/models/stock_location.rb +7 -0
- data/lib/spree_client/models/stock_movement.rb +7 -0
- data/lib/spree_client/models/store.rb +7 -0
- data/lib/spree_client/models/taxonomy.rb +5 -0
- data/lib/spree_client/models/variant.rb +7 -0
- metadata +79 -118
- data/.gitignore +0 -17
- data/.travis.yml +0 -9
- data/CONTRIBUTING.md +0 -8
- data/Gemfile +0 -3
- data/LICENSE +0 -22
- data/Rakefile +0 -7
- data/lib/spree-api-client.rb +0 -49
- data/lib/spree-api-client/addresses.rb +0 -15
- data/lib/spree-api-client/connection.rb +0 -30
- data/lib/spree-api-client/countries.rb +0 -15
- data/lib/spree-api-client/line_items.rb +0 -19
- data/lib/spree-api-client/orders.rb +0 -31
- data/lib/spree-api-client/payments.rb +0 -43
- data/lib/spree-api-client/products.rb +0 -31
- data/lib/spree-api-client/properties.rb +0 -31
- data/lib/spree-api-client/request.rb +0 -49
- data/lib/spree-api-client/return_authorizations.rb +0 -31
- data/lib/spree-api-client/shipments.rb +0 -15
- data/lib/spree-api-client/taxonomies.rb +0 -31
- data/lib/spree-api-client/taxons.rb +0 -27
- data/lib/spree-api-client/variants.rb +0 -31
- data/lib/spree-api-client/version.rb +0 -7
- data/lib/spree-api-client/zones.rb +0 -31
- data/spec/addresses_spec.rb +0 -11
- data/spec/client_spec.rb +0 -31
- data/spec/countries_spec.rb +0 -11
- data/spec/orders_spec.rb +0 -11
- data/spec/payments_spec.rb +0 -11
- data/spec/products_spec.rb +0 -11
- data/spec/properties_spec.rb +0 -11
- data/spec/return_authorizations_spec.rb +0 -11
- data/spec/shipments_spec.rb +0 -11
- data/spec/spec_helper.rb +0 -5
- data/spec/taxonomies_spec.rb +0 -11
- data/spec/taxons_spec.rb +0 -11
- data/spec/variants_spec.rb +0 -11
- data/spec/zones_spec.rb +0 -11
- data/spree-api-client.gemspec +0 -27
data/Rakefile
DELETED
data/lib/spree-api-client.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'faraday_middleware'
|
2
|
-
require "spree-api-client/version"
|
3
|
-
|
4
|
-
require 'spree-api-client/connection'
|
5
|
-
require 'spree-api-client/request'
|
6
|
-
|
7
|
-
require 'spree-api-client/products'
|
8
|
-
require 'spree-api-client/variants'
|
9
|
-
require 'spree-api-client/orders'
|
10
|
-
require 'spree-api-client/taxonomies'
|
11
|
-
require 'spree-api-client/addresses'
|
12
|
-
require 'spree-api-client/countries'
|
13
|
-
require 'spree-api-client/zones'
|
14
|
-
require 'spree-api-client/properties'
|
15
|
-
require 'spree-api-client/line_items'
|
16
|
-
require 'spree-api-client/return_authorizations'
|
17
|
-
require 'spree-api-client/taxons'
|
18
|
-
require 'spree-api-client/payments'
|
19
|
-
require 'spree-api-client/shipments'
|
20
|
-
|
21
|
-
module Spree
|
22
|
-
module API
|
23
|
-
class Client
|
24
|
-
include Spree::API::Client::Connection
|
25
|
-
include Spree::API::Client::Request
|
26
|
-
|
27
|
-
include Spree::API::Client::Products
|
28
|
-
include Spree::API::Client::Variants
|
29
|
-
include Spree::API::Client::Orders
|
30
|
-
include Spree::API::Client::Taxonomies
|
31
|
-
include Spree::API::Client::Addresses
|
32
|
-
include Spree::API::Client::Countries
|
33
|
-
include Spree::API::Client::Zones
|
34
|
-
include Spree::API::Client::Properties
|
35
|
-
include Spree::API::Client::LineItems
|
36
|
-
include Spree::API::Client::ReturnAuthorizations
|
37
|
-
include Spree::API::Client::Taxons
|
38
|
-
include Spree::API::Client::Payments
|
39
|
-
include Spree::API::Client::Shipments
|
40
|
-
|
41
|
-
attr_accessor :api_endpoint, :api_token, :per_page
|
42
|
-
def initialize(api_endpoint, api_token, options={})
|
43
|
-
@api_endpoint = api_endpoint
|
44
|
-
@api_token = api_token
|
45
|
-
@per_page = options.fetch(:per_page, 30)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Connection
|
5
|
-
def connection(options={})
|
6
|
-
options = {
|
7
|
-
:authenticate => true,
|
8
|
-
:force_urlencoded => false,
|
9
|
-
:raw => false,
|
10
|
-
:ssl => { :verify => false },
|
11
|
-
:url => 'http://localhost:4000/store/api', #api_endpoint
|
12
|
-
:path_prefix => '/api'
|
13
|
-
}.merge(options)
|
14
|
-
|
15
|
-
connection = Faraday.new(options) do |builder|
|
16
|
-
builder.request :json
|
17
|
-
|
18
|
-
builder.use FaradayMiddleware::FollowRedirects
|
19
|
-
builder.use FaradayMiddleware::Mashify
|
20
|
-
|
21
|
-
builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
|
22
|
-
|
23
|
-
builder.adapter Faraday.default_adapter
|
24
|
-
end
|
25
|
-
connection
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module LineItems
|
5
|
-
def create_line_item(order_number, options={})
|
6
|
-
post("orders/#{order_number}/line_items/", options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def update_line_item(order_number, line_item_id, options={})
|
10
|
-
put("orders/#{order_number}/line_items/#{line_item_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def delete_line_item(order_number, line_item_id, options={})
|
14
|
-
delete("orders/#{order_number}/line_items/#{line_item_id}", options)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Orders
|
5
|
-
def orders(options={})
|
6
|
-
get('orders', options)['orders']
|
7
|
-
end
|
8
|
-
|
9
|
-
def order(order_number, options={})
|
10
|
-
get("orders/#{order_number}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_order(options={})
|
14
|
-
post("orders", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def update_order_address(order_number, options={})
|
18
|
-
put("orders/#{order_number}/address", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def set_order_shipping_method(order_number, shipping_method_id, options={})
|
22
|
-
put("orders/#{order_number}", options.merge(:shipping_method_id => shipping_method_id))
|
23
|
-
end
|
24
|
-
|
25
|
-
def empty_order(order_number, options={})
|
26
|
-
put("orders/#{order_number}/empty", options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Payments
|
5
|
-
def payments(order_number, options={})
|
6
|
-
get("orders/#{order_number}/payments", options)['payments']
|
7
|
-
end
|
8
|
-
|
9
|
-
def payment(order_number, payment_id, options={})
|
10
|
-
get("orders/#{order_number}/payments/#{payment_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_payment(order_number, options={})
|
14
|
-
get("orders/#{order_number}/payments/new", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_payment(order_number, options={})
|
18
|
-
post("orders/#{order_number}/payments/", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def authorize_payment(order_number, payment_id, options={})
|
22
|
-
put("orders/#{order_number}/payments/#{payment_id}/authorize", options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def capture_payment(order_number, payment_id, options={})
|
26
|
-
put("orders/#{order_number}/payments/#{payment_id}/capture", options)
|
27
|
-
end
|
28
|
-
|
29
|
-
def purchase_payment(order_number, payment_id, options={})
|
30
|
-
put("orders/#{order_number}/payments/#{payment_id}/purchase", options)
|
31
|
-
end
|
32
|
-
|
33
|
-
def void_payment(order_number, payment_id, options={})
|
34
|
-
put("orders/#{order_number}/payments/#{payment_id}.void", options)
|
35
|
-
end
|
36
|
-
|
37
|
-
def credit_payment(order_number, payment_id, options={})
|
38
|
-
put("orders/#{order_number}/payments/#{payment_id}/credit", options)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Products
|
5
|
-
def products(options={})
|
6
|
-
get('products', options)['products']
|
7
|
-
end
|
8
|
-
|
9
|
-
def product(permalink_or_id, options={})
|
10
|
-
get("products/#{permalink_or_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_product(options={})
|
14
|
-
get("products/#{permalink_or_id}/new", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_product(options={})
|
18
|
-
post("products", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def update_product(permalink_or_id, options={})
|
22
|
-
put("products/#{permalink_or_id}", options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def delete_product(permalink_or_id, options={})
|
26
|
-
delete("products/#{permalink_or_id}", options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Properties
|
5
|
-
def properties(product_id, options={})
|
6
|
-
get("products/#{product_id}/product_properties", options)['product_properties']
|
7
|
-
end
|
8
|
-
|
9
|
-
def property(product_id, property_id, options={})
|
10
|
-
get("products/#{product_id}/product_properties/#{property_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_property(product_id, options={})
|
14
|
-
get("products/#{product_id}/product_properties/new", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_property(product_id, options={})
|
18
|
-
post("products/#{product_id}/product_properties/", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def update_property(product_id, property_id, options={})
|
22
|
-
put("products/#{product_id}/product_properties/#{property_id}", options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def delete_property(product_id, property_id, options={})
|
26
|
-
delete("products/#{product_id}/product_properties/#{property_id}", options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Request
|
5
|
-
def request(method, path, options = {})
|
6
|
-
token = options.delete(:api_token) || api_token
|
7
|
-
|
8
|
-
response = connection.send(method) do |request|
|
9
|
-
|
10
|
-
request.headers['Accept'] = options.delete(:accept) || 'application/json'
|
11
|
-
|
12
|
-
if token
|
13
|
-
request.headers['X-Spree-Token'] = token
|
14
|
-
end
|
15
|
-
|
16
|
-
case method
|
17
|
-
when :get
|
18
|
-
options.merge!(:per_page => per_page) if per_page
|
19
|
-
request.url(path, options)
|
20
|
-
when :delete, :head
|
21
|
-
request.url(path, options)
|
22
|
-
when :patch, :post, :put
|
23
|
-
request.path = path
|
24
|
-
request.body = MultiJson.dump(options) unless options.empty?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
response
|
29
|
-
end
|
30
|
-
|
31
|
-
def get(path, options = {})
|
32
|
-
request(:get, path, options = {}).body
|
33
|
-
end
|
34
|
-
|
35
|
-
def post(path, options={})
|
36
|
-
request(:post, path, options).body
|
37
|
-
end
|
38
|
-
|
39
|
-
def put(path, options={})
|
40
|
-
request(:put, path, options).body
|
41
|
-
end
|
42
|
-
|
43
|
-
def delete(path, options={})
|
44
|
-
request(:delete, path, options).body
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module ReturnAuthorizations
|
5
|
-
def return_authorizations(order_number, options={})
|
6
|
-
get("orders/#{order_number}/return_authorizations", options)['return_authorizations']
|
7
|
-
end
|
8
|
-
|
9
|
-
def return_authorization(order_number, return_authorization_id, options={})
|
10
|
-
get("orders/#{order_number}/return_authorizations/#{return_authorization_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_return_authorization(order_number, options={})
|
14
|
-
get("orders/#{order_number}/return_authorizations/new", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_return_authorization(order_number, options={})
|
18
|
-
post("orders/#{order_number}/return_authorizations/", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def update_return_authorization(product_id, return_authorization_id, options={})
|
22
|
-
put("orders/#{order_number}/return_authorizations/#{return_authorization_id}", options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def delete_return_authorization(product_id, return_authorization_id, options={})
|
26
|
-
delete("orders/#{order_number}/return_authorizations/#{return_authorization_id}", options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Shipments
|
5
|
-
def shipment_ready(order_number, shipment_id, options={})
|
6
|
-
put("orders/#{order_number}/shipments/#{shipment_id}/ready", options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def ship_shipment(order_number, shipment_id, options={})
|
10
|
-
put("orders/#{order_number}/shipments/#{shipment_id}/ship", options)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Taxonomies
|
5
|
-
def taxonomies(options={})
|
6
|
-
get('taxonomies', options)['taxonomies']
|
7
|
-
end
|
8
|
-
|
9
|
-
def taxonomy(id, options={})
|
10
|
-
get("taxonomies/#{id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def new_taxonomy(options={})
|
14
|
-
get("taxonomies/#{id}/new", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_taxonomy(options={})
|
18
|
-
post("taxonomies", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def update_taxonomy(id, options={})
|
22
|
-
put("taxonomies/#{id}", options)
|
23
|
-
end
|
24
|
-
|
25
|
-
def delete_taxonomy(id, options={})
|
26
|
-
delete("taxonomies/#{id}", options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module API
|
3
|
-
class Client
|
4
|
-
module Taxons
|
5
|
-
def taxons(taxonomy_id, options={})
|
6
|
-
get("taxonomies/#{taxonomy_id}/taxons", options)
|
7
|
-
end
|
8
|
-
|
9
|
-
def taxon(taxonomy_id, taxon_id, options={})
|
10
|
-
get("taxonomies/#{taxonomy_id}/taxons/#{taxon_id}", options)
|
11
|
-
end
|
12
|
-
|
13
|
-
def create_taxon(taxonomy_id, options={})
|
14
|
-
post("taxonomies/#{taxonomy_id}/taxons/", options)
|
15
|
-
end
|
16
|
-
|
17
|
-
def update_taxon(taxonomy_id, taxon_id, options={})
|
18
|
-
put("taxonomies/#{taxonomy_id}/taxons/#{taxon_id}", options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete_taxon(taxonomy_id, taxon_id, options={})
|
22
|
-
delete("taxonomies/#{taxonomy_id}/taxons/#{taxon_id}", options)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|