diff --git a/.gitignore b/.gitignore index d87d4be..a955cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ spec/reports test/tmp test/version_tmp tmp +.DS_Store diff --git a/Rakefile b/Rakefile index 2995527..809eb56 100644 --- a/Rakefile +++ b/Rakefile @@ -1 +1,2 @@ require "bundler/gem_tasks" + diff --git a/ecwid_api.gemspec b/ecwid_api.gemspec index fbde583..e7949a3 100644 --- a/ecwid_api.gemspec +++ b/ecwid_api.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake", "~> 0" - spec.add_development_dependency "rspec", "~> 2.14", ">= 2.14.1" + spec.add_development_dependency "rspec", "~> 3.5", ">= 3.5" spec.add_dependency "faraday", "~> 0.9.0" spec.add_dependency "faraday_middleware", "~> 0.9.1" diff --git a/lib/ecwid_api.rb b/lib/ecwid_api.rb index 888bb75..0465d99 100644 --- a/lib/ecwid_api.rb +++ b/lib/ecwid_api.rb @@ -16,10 +16,12 @@ module EcwidApi require_relative "ecwid_api/entity" require_relative "ecwid_api/category" + require_relative "ecwid_api/customer" require_relative "ecwid_api/order" require_relative "ecwid_api/order_item" require_relative "ecwid_api/person" require_relative "ecwid_api/product_combination" - require_relative "ecwid_api/product" + require_relative "ecwid_api/product_type" + require_relative "ecwid_api/product_type_attribute" end diff --git a/lib/ecwid_api/api.rb b/lib/ecwid_api/api.rb index 352d799..6ab87fb 100644 --- a/lib/ecwid_api/api.rb +++ b/lib/ecwid_api/api.rb @@ -1,9 +1,11 @@ module EcwidApi module Api require_relative "api/base" - require_relative "api/orders" - require_relative "api/products" require_relative "api/categories" + require_relative "api/customers" + require_relative "api/orders" require_relative "api/product_combinations" + require_relative "api/product_types" + require_relative "api/products" end -end \ No newline at end of file +end diff --git a/lib/ecwid_api/api/customers.rb b/lib/ecwid_api/api/customers.rb new file mode 100644 index 0000000..bae848e --- /dev/null +++ b/lib/ecwid_api/api/customers.rb @@ -0,0 +1,53 @@ +require_relative "../paged_ecwid_response" + +module EcwidApi + module Api + class Customers < Base + # Public: Get all of the Customer objects for the Ecwid store + # + # Returns an Array of Customer objects + def all(params = {}) + PagedEcwidResponse.new(client, "customers", params) do |customer_hash| + Customer.new(customer_hash, client: client) + end + end + + # Public: Finds a single customer by customer ID + # + # id - an Ecwid customer ID + # + # Returns a Customer object, or nil if one can't be found + def find(id) + response = client.get("customers/#{id}") + if response.success? + Customer.new(response.body, client: client) + end + end + + # Public: Creates a new Customer + # + # params - a Hash + # + # Raises an Error if there is a problem + # + # Returns a Customer object + def create(params) + response = client.post("customers", params) + find(response.body["id"]) + end + + # Public: Updates an existing Customer + # + # id - the Ecwid customer ID + # params - a Hash + # + # Raises an Error if there is a problem + # + # Returns a Customer object + def update(id, params) + client.put("customers/#{id}", params) + find(id) + end + end + end +end diff --git a/lib/ecwid_api/api/product_types.rb b/lib/ecwid_api/api/product_types.rb new file mode 100644 index 0000000..4993865 --- /dev/null +++ b/lib/ecwid_api/api/product_types.rb @@ -0,0 +1,56 @@ +require_relative "../unpaged_ecwid_response" + +module EcwidApi + module Api + class ProductTypes < Base + # Public: Get all of the ProductType objects for the Ecwid store + # + # Returns an Array of ProductType objects + # NOTE: This endpoint does not behave like other Ecwid endpoints in that + # it does not return paged results. It simply returns every + # result in an array, without a wrapper with an "items" property. + def all(params = {}) + UnpagedEcwidResponse.new(client, "classes") do |product_type_hash| + ProductType.new(product_type_hash, client: client) + end + end + + # Public: Finds a single product_type by product_type ID + # + # id - an Ecwid product_type ID + # + # Returns a ProductType object, or nil if one can't be found + def find(id) + response = client.get("classes/#{id}") + if response.success? + ProductType.new(response.body, client: client) + end + end + + # Public: Creates a new ProductType + # + # params - a Hash + # + # Raises an Error if there is a problem + # + # Returns a ProductType object + def create(params) + response = client.post("classes", params) + find(response.body["id"]) + end + + # Public: Updates an existing ProductType + # + # id - the Ecwid product_type ID + # params - a Hash + # + # Raises an Error if there is a problem + # + # Returns a ProductType object + def update(id, params) + client.put("classes/#{id}", params) + find(id) + end + end + end +end diff --git a/lib/ecwid_api/client.rb b/lib/ecwid_api/client.rb index 11402fd..30c9372 100644 --- a/lib/ecwid_api/client.rb +++ b/lib/ecwid_api/client.rb @@ -20,7 +20,7 @@ class Client attr_reader :token attr_reader :adapter - attr_reader :connection, :categories, :orders, :products + attr_reader :connection, :categories, :customers, :orders, :products, :product_types # Public: Initializes a new Client to interact with the API # @@ -41,9 +41,11 @@ def initialize(store_id, token, adapter = Faraday.default_adapter) conn.adapter adapter end - @categories = Api::Categories.new(self) - @orders = Api::Orders.new(self) - @products = Api::Products.new(self) + @categories = Api::Categories.new(self) + @customers = Api::Customers.new(self) + @orders = Api::Orders.new(self) + @products = Api::Products.new(self) + @product_types = Api::ProductTypes.new(self) end # Public: The URL of the API for the Ecwid Store @@ -97,4 +99,4 @@ def raise_on_failure(response) end end end -end \ No newline at end of file +end diff --git a/lib/ecwid_api/customer.rb b/lib/ecwid_api/customer.rb new file mode 100644 index 0000000..022464c --- /dev/null +++ b/lib/ecwid_api/customer.rb @@ -0,0 +1,10 @@ +module EcwidApi + class Customer < Entity + self.url_root = "customers" + + ecwid_reader :name, :email, :totalOrderCount, :customerGroupId, :customerGroupName + + ecwid_writer :name, :email + + end +end diff --git a/lib/ecwid_api/order.rb b/lib/ecwid_api/order.rb index c00b539..8f3549e 100644 --- a/lib/ecwid_api/order.rb +++ b/lib/ecwid_api/order.rb @@ -51,7 +51,7 @@ def billing_person # Public: Returns the shipping person # - # If there isn't a shipping_person, then it is assumed to be the + # If there isn't a shipping_person, then it is assumed to be the # billing_person # def shipping_person @@ -66,7 +66,7 @@ def items def fulfillment_status=(status) status = status.to_s.upcase unless VALID_FULFILLMENT_STATUSES.include?(status) - raise Error("#{status} is an invalid fullfillment status") + raise ::StandardError.new("#{status} is an invalid fullfillment status") end super(status) end @@ -85,4 +85,4 @@ def build_shipping_person @shipping_person ||= data["shippingPerson"] && Person.new(data["shippingPerson"]) end end -end \ No newline at end of file +end diff --git a/lib/ecwid_api/product_type.rb b/lib/ecwid_api/product_type.rb new file mode 100644 index 0000000..253d383 --- /dev/null +++ b/lib/ecwid_api/product_type.rb @@ -0,0 +1,18 @@ +module EcwidApi + class ProductType < Entity + + self.url_root = "classes" + + ecwid_reader :id, :name, :googleTaxonomy, :attributes + + ecwid_writer :name, :attributes + + + # Public: Returns a Array of `ProductTypeAttribute` objects + def attributes + @attributes ||= data["attributes"].map { |attribute| ProductTypeAttribute.new(attribute) } + end + + + end +end diff --git a/lib/ecwid_api/product_type_attribute.rb b/lib/ecwid_api/product_type_attribute.rb new file mode 100644 index 0000000..9f53a9f --- /dev/null +++ b/lib/ecwid_api/product_type_attribute.rb @@ -0,0 +1,28 @@ +module EcwidApi + class ProductTypeAttribute < Entity + + ecwid_reader :id, :name, :type, :show + + VALID_TYPES = %w(CUSTOM UPC BRAND GENDER AGE_GROUP COLOR SIZE PRICE_PER_UNIT UNITS_IN_PRODUCT) + VALID_SHOWS = %w(NOTSHOW DESCR PRICE) + + + def type=(type_type) + type_type = type_type.to_s.upcase + unless VALID_TYPES.include?(type_type) + raise ::StandardError.new("#{type_type} is an invalid 'type'") + end + super(type_type) + end + + + def show=(show_type) + show_type = show_type.to_s.upcase + unless VALID_SHOWS.include?(show_type) + raise ::StandardError.new("#{show_type} is an invalid 'show'") + end + super(show_type) + end + + end +end diff --git a/lib/ecwid_api/unpaged_ecwid_response.rb b/lib/ecwid_api/unpaged_ecwid_response.rb new file mode 100644 index 0000000..ff7d8ff --- /dev/null +++ b/lib/ecwid_api/unpaged_ecwid_response.rb @@ -0,0 +1,38 @@ + +# Public: Presents an Ecwid response as an Array +# +# Example +# +# response = UnpagedEcwidResponse.new(client, "products", priceFrom: 10) do |product_hash| +# Product.new(product_hash, click: client) +# end +# +# response.each do |product| +# # do stuff the the product +# end +# +module EcwidApi + class UnpagedEcwidResponse + include Enumerable + extend Forwardable + + def_delegators :@records, *Enumerable.instance_methods + + # Public: Initialize a new UnpagedEcwidResponse + # + # client - an EcwidApi::Client + # path - a String that is the path to retrieve from the client + # params - a Hash of parameters to pass along with the request + # &block - a Block that processes each item returned in the Response + # + def initialize(client, path, params = {}, &block) + block ||= Proc.new { |item| item } + @records = [] + + response = client.get(path, params) + response.body.each do |item| + @records << block.call(item) + end + end + end +end diff --git a/lib/ecwid_api/version.rb b/lib/ecwid_api/version.rb index c0b8cd8..4505820 100644 --- a/lib/ecwid_api/version.rb +++ b/lib/ecwid_api/version.rb @@ -1,3 +1,3 @@ module EcwidApi - VERSION = "0.2.2" + VERSION = "0.2.4" end diff --git a/spec/api/customers_spec.rb b/spec/api/customers_spec.rb new file mode 100644 index 0000000..b232e67 --- /dev/null +++ b/spec/api/customers_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe EcwidApi::Api::Customers, faraday: true do + subject { client.customers } + + describe "#all" do + it "passes any other parameters through" do + expect(client).to receive(:get).with("customers", hash_including(from_date: '1982-05-17')) + subject.all(from_date: '1982-05-17') + end + + it "gets the proper response count (see fixture)" do + expect(subject.all.count).to eq 5 + end + + it "gets the proper customer (see fixture)" do + expect(subject.all.first.name).to eq "Abe Doe" + end + end +end diff --git a/spec/api/orders_spec.rb b/spec/api/orders_spec.rb index ea531f6..7f29b2e 100644 --- a/spec/api/orders_spec.rb +++ b/spec/api/orders_spec.rb @@ -10,21 +10,21 @@ end it "gets the proper response (see fixtures)" do - subject.all.count.should == 2 + expect(subject.all.count).to be 2 end it "gets EcwidApi::Order types" do - subject.all.all? { |order| order.is_a?(EcwidApi::Order) }.should be_true + expect(subject.all.all? { |order| order.is_a?(EcwidApi::Order) }).to be(true) end end describe "#find" do it "is an `EcwidApi::Order`" do - subject.find(35).is_a?(EcwidApi::Order).should be_true + expect(subject.find(35)).to be_a(EcwidApi::Order) end it "is nil when not found" do - subject.find(404).should be_nil + expect(subject.find(404)).to be_nil end end -end \ No newline at end of file +end diff --git a/spec/api/product_types_spec.rb b/spec/api/product_types_spec.rb new file mode 100644 index 0000000..bd78d65 --- /dev/null +++ b/spec/api/product_types_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe EcwidApi::Api::ProductTypes, faraday: true do + subject { client.product_types } + + describe "#all" do + it "returns an array" do + expect(client).to receive(:get).with("classes", {}).and_call_original + subject.all + end + + it "gets the proper response count (see fixture)" do + expect(subject.all.count).to eq 2 + end + + it "gets the proper product_type (see fixture)" do + expect(subject.all.first.name).to eq "Foo" + end + end +end diff --git a/spec/api/products_spec.rb b/spec/api/products_spec.rb deleted file mode 100644 index 6567e04..0000000 --- a/spec/api/products_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe EcwidApi::Api::Products, faraday: true do - subject { client.products } - - describe "#all" do - it "passes any other paramters through" do - expect(client).to receive(:get).with("products", hash_including(from_date: '1982-05-17')) - subject.all(from_date: '1982-05-17') - end - - it "gets the proper response count (see fixture)" do - subject.all.count.should == 5 - end - - it "gets the proper product (see fixture)" do - subject.all.first.sku.should == "NC53090" - end - end -end \ No newline at end of file diff --git a/spec/category_spec.rb b/spec/category_spec.rb index 66792a1..fa8b342 100644 --- a/spec/category_spec.rb +++ b/spec/category_spec.rb @@ -27,8 +27,8 @@ it "returns nil" do expect(client.categories).to_not receive(:find) - subject.parent.should be_nil + expect(subject.parent).to be_nil end end end -end \ No newline at end of file +end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 093f6d5..47eb9fe 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -4,7 +4,7 @@ subject { client } describe "#store_url" do - its(:store_url) { "http://app.ecwid.com/api/v3/12345" } + it { is_expected.to have_attributes(store_url: "https://app.ecwid.com/api/v3/12345") } end describe "#get", faraday: true do @@ -15,7 +15,7 @@ end it "returns a Faraday::Response" do - subject.get("categories", parent: 1).is_a?(Faraday::Response).should be_true + expect(subject.get("categories", parent: 1)).to be_a(Faraday::Response) end end -end \ No newline at end of file +end diff --git a/spec/entity_spec.rb b/spec/entity_spec.rb index 883a92d..0b5bc82 100644 --- a/spec/entity_spec.rb +++ b/spec/entity_spec.rb @@ -18,7 +18,7 @@ class EntityUrlSubject < EcwidApi::Entity self.url_root = -> { "parent/#{parent_id}/and" } end -describe EcwidApi::Entity do +RSpec.describe EcwidApi::Entity do let(:data) do { "id" => 123, @@ -34,42 +34,42 @@ class EntityUrlSubject < EcwidApi::Entity subject { EntitySubject.new(data) } describe "::url_root" do - its(:url) { should == "stuff/123" } + it { is_expected.to have_attributes(url: "stuff/123") } context "with a proc" do subject { EntityUrlSubject.new(data) } - its(:url) { should == "parent/456/and/123" } + it { is_expected.to have_attributes(url: "parent/456/and/123") } end end describe "#[]" do it "gets data with a symbol key" do - subject[:id].should == 123 + expect(subject[:id]).to eq 123 end it "gets data with a string key" do - subject["parentId"].should == 456 + expect(subject["parentId"]).to eq 456 end it "get nil for unknown data" do - subject["whatever"].should be_nil + expect(subject["whatever"]).to be_nil end it "gets attributes not revealed by ecwid_reader or ecwid_accessor" do - subject["hidden"].should == "tee hee" + expect(subject["hidden"]).to eq "tee hee" end end describe "overrides" do - its(:override) { should == "UPCASE ME" } + it { is_expected.to have_attributes(override: "UPCASE ME") } end describe "accessors" do describe "::ecwid_reader" do it "makes data accessible with a snake cased method" do - subject.parent_id.should == 456 + expect(subject.parent_id).to eq 456 end it "doesn't have a writer" do @@ -80,7 +80,7 @@ class EntityUrlSubject < EcwidApi::Entity describe "::ecwid_writer" do it "creates a writer method" do subject.write_only = "yee haw!" - subject["writeOnly"].should == "yee haw!" + expect(subject["writeOnly"]).to eq "yee haw!" end it "doesn't have a reader" do @@ -91,13 +91,13 @@ class EntityUrlSubject < EcwidApi::Entity describe "::ecwid_accessor" do it "creates a reader and a writer" do subject.the_status = "MATURE" - subject.the_status.should == "MATURE" + expect(subject.the_status).to eq "MATURE" end end describe "without an accessor" do it "is accessible with []" do - subject[:hidden].should == "tee hee" + expect(subject[:hidden]).to eq "tee hee" end it "doesn't have an access method" do @@ -105,4 +105,4 @@ class EntityUrlSubject < EcwidApi::Entity end end end -end \ No newline at end of file +end diff --git a/spec/fixtures/classes.json b/spec/fixtures/classes.json new file mode 100644 index 0000000..9322171 --- /dev/null +++ b/spec/fixtures/classes.json @@ -0,0 +1,44 @@ +[ + { + "id": 1, + "name": "Foo", + "googleTaxonomy": "This > That > Other > Foos", + "attributes": [{ + "id": 111, + "name": "UPC", + "type": "UPC", + "show": "DESCR" + }, + { + "id": 222, + "name": "Brand", + "type": "BRAND", + "show": "DESCR" + } + ] + }, + { + "id": 2, + "name": "Bar", + "googleTaxonomy": "This > That > Other > Bars", + "attributes": [{ + "id": 333, + "name": "UPC", + "type": "UPC", + "show": "DESCR" + }, + { + "id": 444, + "name": "Brand", + "type": "BRAND", + "show": "DESCR" + }, + { + "id": 555, + "name": "Blah", + "type": "BRAND", + "show": "NOTSHOW" + } + ] + } +] diff --git a/spec/fixtures/customers.json b/spec/fixtures/customers.json new file mode 100644 index 0000000..30b8e15 --- /dev/null +++ b/spec/fixtures/customers.json @@ -0,0 +1,48 @@ +{ + "total": 5, + "count": 5, + "offset": 0, + "limit": 100, + "items": [ + { + "id": 1, + "name": "Abe Doe", + "email": "abe@example.com", + "totalOrderCount": 1, + "customerGroupId": 0, + "customerGroupName": "General" + }, + { + "id": 2, + "name": "Bob Doe", + "email": "bob@example.com", + "totalOrderCount": 2, + "customerGroupId": 0, + "customerGroupName": "General" + }, + { + "id": 3, + "name": "Chris Doe", + "email": "chris@example.com", + "totalOrderCount": 3, + "customerGroupId": 0, + "customerGroupName": "General" + }, + { + "id": 4, + "name": "Debby Doe", + "email": "debby@example.com", + "totalOrderCount": 0, + "customerGroupId": 0, + "customerGroupName": "General" + }, + { + "id": 5, + "name": "Ellen Doe", + "email": "ellen@example.com", + "totalOrderCount": 0, + "customerGroupId": 0, + "customerGroupName": "General" + } + ] +} diff --git a/spec/fixtures/products.json b/spec/fixtures/products.json deleted file mode 100644 index 48716b9..0000000 --- a/spec/fixtures/products.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "total": 5, - "count": 5, - "offset": 0, - "limit": 10, - "items": [ - { - "id": 41316136, - "sku": "NC53090", - "smallThumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242429875.jpg", - "thumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242429874.jpg", - "imageUrl": "http://images-cdn.ecwid.com/images/4881025/245156912.jpg", - "originalImageUrl": "http://images-cdn.ecwid.com/images/4881025/245156911.jpg", - "unlimited": true, - "inStock": true, - "name": "Book: Therapeutic Hand Splints: A Rational Approach", - "price": 80.95, - "weight": 0.063, - "url": "http://preview.myncmstore.com#!/em-Book-em-Therapeutic-Hand-Splints-A-Rational-Approach/p/41316136", - "created": "2014-09-13 01:45:38 -0700", - "updated": "2014-10-15 09:01:31 -0700", - "productClassId": 0, - "enabled": false, - "description": "

Mechanical and biomechanical considerations of hand splinting.
This book takes an in-depth look into the design, manufacture and application of splints for the upper limb and specifically the hand. The first section, Mechanical Considerations, includes immobilization and mobilization splinting, technical considerations, splinting materials and components. The second section, Biomechanical Considerations, addresses anatomical shape and positioning, volume control and pressure, and biokinematic and biokinetic systems. Includes numerous photographs and illustrations. Soft cover, 214 pages. Written by Paul Van Lede, MS, OT and Griet van Veldhoven, OT. Copyright 1998.

", - "descriptionTruncated": false, - "priceInProductList": 80.95, - "categoryIds": [], - "defaultCategoryId": 0, - "favorites": { - "count": 0, - "displayedCount": "0" - } - }, - { - "id": 41316720, - "sku": "T631", - "smallThumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242433086.jpg", - "thumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242433085.jpg", - "imageUrl": "http://images-cdn.ecwid.com/images/4881025/245154405.jpg", - "originalImageUrl": "http://images-cdn.ecwid.com/images/4881025/245154403.jpg", - "unlimited": true, - "inStock": true, - "name": "SportsArt T631", - "price": 4315, - "weight": 595, - "url": "http://preview.myncmstore.com#!/SportsArt-T631/p/41316720", - "created": "2014-09-13 01:46:13 -0700", - "updated": "2014-10-15 08:58:41 -0700", - "productClassId": 0, - "enabled": false, - "description": "

4.0 hp ECO-POWR™ motor uses up to 32% less energy without compromising power.

Motor - 4 hp DC

Speed range - .1 to 12 mph (.16 to 19km/h)

Incline range - 0 to 15%

Deck Cushioning - 4-way reversible phenolic, My-Flex™

Display/Feedback - Dot Matrix and LEDs

Programs - 3 Interval (1:1, 1:2, 2:2), Random (x10,000), 2 Glute (30 min, and 45 min), 3 Hill, HRC Cardio, HRC Weight Loss, Quick Star, Manual/Track, Zone Trainer™, Fitness Tests (Bruce, Gerkin, WFI, Army, Marines)

Medical rails - Optional

Maximum user weight - 450 lbs. (181kg)

Unit dimensions - 83.5\" x 38.6\" x 56.3\" (212 x 98 x 143)

Unit weight - 297 lbs. (135kg)

Warranty - Lifetime frame, 5 years parts, Dedicated Power Supply

Power requirements - 120 VAC, 60 Hz, 12A, 1440W; Plug UL NEMA 5-15; Cord 14 AWG CSA-approved; Fuse 12A (6x30 mm), 100-120V, Fast blow

Shipping - Call for freight quote

", - "descriptionTruncated": false, - "priceInProductList": 4315, - "categoryIds": [], - "defaultCategoryId": 0, - "favorites": { - "count": 0, - "displayedCount": "0" - } - }, - { - "id": 41316721, - "sku": "T611", - "smallThumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242433090.jpg", - "thumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242433089.jpg", - "imageUrl": "http://images-cdn.ecwid.com/images/4881025/245154466.jpg", - "originalImageUrl": "http://images-cdn.ecwid.com/images/4881025/245154465.jpg", - "unlimited": true, - "inStock": true, - "name": "SportsArt T611", - "price": 2595, - "weight": 0, - "url": "http://preview.myncmstore.com#!/SportsArt-T611/p/41316721", - "created": "2014-09-13 01:46:13 -0700", - "updated": "2014-10-15 08:58:41 -0700", - "productClassId": 0, - "enabled": false, - "description": "

Powerful 3.0 hp DC motor with a large 20\" x 58\" running surface.

Motor: 3 hp DC

Speed range: .1 to 12 mph (.16 to 19km/h)

Incline range: -3 to 15%

Deck Cushioning: 4-way reversible phenolic, My-Flex™

Display/Feedback: Tri-Color Dot Matrix and LEDs

Programs: Programmable Interval, Random (x10,000), 2 Glute (30 min, and 45 min), 3 Hill, HRC Cardio, HRC Weight Loss, Quick Star, Manual/Track, Zone Trainer™

Medical rails: Optional

Maximum user weight: 400 lbs. (181kg)

Unit dimensions: 77.5\" x 38\" x 53\" (197 x 97 x 35cm)

Unit weight: 229 lbs. (104kg)

Warranty: Lifetime frame, 5 years parts, Dedicated Power Supply

Power requirements: 120 VAC, 60 Hz, 12A, 1440W; Plug UL NEMA 5-15; Cord 14 AWG CSA-approved; Fuse 12A (6x30 mm), 100-120V, Fast blow

Shipping: Call for freight quote

", - "descriptionTruncated": false, - "priceInProductList": 2595, - "categoryIds": [], - "defaultCategoryId": 0, - "favorites": { - "count": 0, - "displayedCount": "0" - } - }, - { - "id": 41316486, - "sku": "NC89048", - "smallThumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242432163.jpg", - "thumbnailUrl": "http://images-cdn.ecwid.com/images/4881025/242432162.jpg", - "imageUrl": "http://images-cdn.ecwid.com/images/4881025/245153078.jpg", - "originalImageUrl": "http://images-cdn.ecwid.com/images/4881025/245153077.jpg", - "unlimited": true, - "inStock": true, - "name": "DVD: Clinical Kinesio Taping", - "price": 41.95, - "weight": 0.192, - "url": "http://preview.myncmstore.com#!/DVD-Clinical-Kinesio-Taping/p/41316486", - "created": "2014-09-13 01:45:57 -0700", - "updated": "2014-10-15 08:56:50 -0700", - "productClassId": 0, - "enabled": false, - "description": "

Introduction, explanation and application of the Kinesio Taping Method.

Certified Kinesio Taping Intstructor Jim Wallis, MS, ATC demonstrates step-by-step application of Kinesio Taping Techniques.  Copyright 2000.

", - "descriptionTruncated": false, - "priceInProductList": 41.95, - "categoryIds": [], - "defaultCategoryId": 0, - "favorites": { - "count": 0, - "displayedCount": "0" - } - }, - { - "id": 43428452, - "sku": "META-2961", - "unlimited": true, - "inStock": true, - "name": "English Pantyhose Aid", - "price": 0, - "weight": 0, - "url": "http://preview.myncmstore.com#!/English-Pantyhose-Aid/p/43428452", - "created": "2014-10-21 14:44:31 -0700", - "updated": "2014-10-21 14:44:31 -0700", - "productClassId": 0, - "enabled": true, - "description": "

test

", - "descriptionTruncated": false, - "priceInProductList": 0, - "categoryIds": [ - 11056311 - ], - "defaultCategoryId": 11056311, - "favorites": { - "count": 0, - "displayedCount": "0" - } - } - ] -} \ No newline at end of file diff --git a/spec/helpers/client.rb b/spec/helpers/client.rb index 5490bab..938300f 100644 --- a/spec/helpers/client.rb +++ b/spec/helpers/client.rb @@ -7,7 +7,7 @@ def client end def fixtures - %w(categories category orders products) + %w(categories customers category orders products classes) end def faraday_stubs @@ -18,6 +18,8 @@ def faraday_stubs stub.get("/categories/5") { [200, {"Content-Type" => "application/json"}, File.read("spec/fixtures/category.json") ] } stub.get("/orders/35") { [200, {"Content-Type" => "application/json"}, File.read("spec/fixtures/order.json") ] } stub.get("/orders/404") { [404, {"Content-Type" => "application/json"}, nil ] } + stub.get("/classes/1") { [200, {"Content-Type" => "application/json"}, File.read("spec/fixtures/classes.json") ] } + stub.get("/classes/404") { [404, {"Content-Type" => "application/json"}, nil ] } end end @@ -29,4 +31,4 @@ def faraday end end end -end \ No newline at end of file +end diff --git a/spec/oauth_spec.rb b/spec/oauth_spec.rb index 1a9ac1c..c7057b9 100644 --- a/spec/oauth_spec.rb +++ b/spec/oauth_spec.rb @@ -10,7 +10,7 @@ end end - its(:oauth_url) { should == "https://my.ecwid.com/api/oauth/authorize?client_id=client_id&scope=scope&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Foauth" } + it { is_expected.to have_attributes(oauth_url: "https://my.ecwid.com/api/oauth/authorize?client_id=client_id&scope=scope&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Foauth") } describe "#access_token(code)" do let(:response) do @@ -30,11 +30,11 @@ end it "returns an object that has the access_token" do - subject.access_token("code").access_token.should == "the_token" + expect(subject.access_token("code").access_token).to eq "the_token" end it "returns an object that has the store_id" do - subject.access_token("code").store_id.should == "12345" + expect(subject.access_token("code").store_id).to eq "12345" end end -end \ No newline at end of file +end diff --git a/spec/order_spec.rb b/spec/order_spec.rb index e279e9f..8085e19 100644 --- a/spec/order_spec.rb +++ b/spec/order_spec.rb @@ -17,45 +17,45 @@ let(:shipping_person) { nil } - its(:id) { should == 123 } + it { is_expected.to have_attributes(id: 123) } describe "#billing_person" do - its(:billing_person) { should be_a(EcwidApi::Person) } + it { expect(subject.billing_person).to be_a(EcwidApi::Person) } it "has the correct data" do - subject.billing_person.name.should == "John Doe" + expect(subject.billing_person.name).to eq "John Doe" end end describe "#shipping_person" do - its(:shipping_person) { should be_a(EcwidApi::Person) } + it { expect(subject.shipping_person).to be_a(EcwidApi::Person) } context "without a shipping person" do let(:shipping_person) { nil } - its(:shipping_person) { should == subject.billing_person } + it { expect(subject.shipping_person).to be(subject.billing_person) } end context "with a shipping person" do let(:shipping_person) { {"name" => "Jane Doe"} } it "has the correct data" do - subject.shipping_person.name.should == "Jane Doe" + expect(subject.shipping_person.name).to eq "Jane Doe" end end end describe "#items" do it "has the correct number of items" do - subject.items.size.should == 1 + expect(subject.items.size).to eq 1 end it "has the correct data" do - subject.items.first.sku.should == "112233" + expect(subject.items.first.sku).to eq "112233" end end describe "#fulfillment_status=" do it "raises an error with an invalid status" do - expect { subject.fulfillment_status = :stuff }.to raise_error + expect { subject.fulfillment_status = :stuff }.to raise_error(StandardError) end it "doesn't raise an error with a valid status" do @@ -65,7 +65,7 @@ describe "#fulfillment_status" do it "is symbolized" do - subject.fulfillment_status.should == :awaiting_processing + expect(subject.fulfillment_status).to eq :awaiting_processing end end -end \ No newline at end of file +end diff --git a/spec/paged_enumerator_spec.rb b/spec/paged_enumerator_spec.rb index 0e9c8af..a7c937f 100644 --- a/spec/paged_enumerator_spec.rb +++ b/spec/paged_enumerator_spec.rb @@ -26,7 +26,7 @@ end it "contains the whole result set" do - subject.to_a.should == %w(1 2 3 4 5 6) + expect(subject.to_a).to eq %w(1 2 3 4 5 6) end it "iterates over each response once" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d675a9a..89c660c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -9,7 +9,6 @@ require "helpers/client" RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus