From 497d353ca5bc36e9c0142d3903a073a354f3efd4 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Mon, 22 Mar 2021 15:35:11 +0700 Subject: [PATCH 01/25] Add Inventory api to Esty --- etsy.gemspec | 2 +- lib/etsy.rb | 1 + lib/etsy/inventory.rb | 16 ++++++++++++++++ lib/etsy/listing.rb | 8 +++++++- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 lib/etsy/inventory.rb diff --git a/etsy.gemspec b/etsy.gemspec index 52351e6..f37d571 100644 --- a/etsy.gemspec +++ b/etsy.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.email = ["reaganpr@gmail.com", "katrina.owen@gmail.com"] gem.description = %q{A friendly Ruby interface to the Etsy API} gem.summary = %q{Provides a friendly ruby-like wrapper for the Etsy API} - gem.homepage = "http://github.com/kytrinyx/etsy" + gem.homepage = "https://github.com/buithehien1991/etsy" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } diff --git a/lib/etsy.rb b/lib/etsy.rb index ca19ef3..26a6f1c 100644 --- a/lib/etsy.rb +++ b/lib/etsy.rb @@ -34,6 +34,7 @@ require 'etsy/receipt' require 'etsy/variation/property_set' require 'etsy/about' +require 'etsy/inventory' # = Etsy: A friendly Ruby interface to the Etsy API # diff --git a/lib/etsy/inventory.rb b/lib/etsy/inventory.rb new file mode 100644 index 0000000..7ed813d --- /dev/null +++ b/lib/etsy/inventory.rb @@ -0,0 +1,16 @@ +module Etsy + class Inventory + include Etsy::Model + + attributes :products, :price_on_property, :quantity_on_property, :sku_on_property + def self.find_all_by_listing_id(listing_id, options={}) + get_all("/listings/#{listing_id}/inventory", options) + end + + private + + def oauth + oauth = (token && secret) ? {:access_token => token, :access_secret => secret} : {} + end + end +end \ No newline at end of file diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index e9eacf3..00ee12e 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -48,7 +48,9 @@ class Listing :tags, :materials, :hue, :saturation, :brightness, :is_black_and_white, :featured_rank, :occasion, :num_favorers, :user_id, :shipping_template_id, :who_made, :when_made, - :style, :category_path, :taxonomy_id, :taxonomy_attributes + :style, :category_path, :taxonomy_id, :taxonomy_attributes, + :sku, :category_id, :taxonomy_path, + :has_variations, :should_auto_renew association :image, :from => 'Images' @@ -56,6 +58,10 @@ def transactions @transactions ||= Transaction.find_all_by_listing_id(id, oauth) end + def inventory + Inventory.find_all_by_listing_id(id, oauth) + end + def receipts transactions.map{|t|t.receipt} end From ce738c1528e2322e42e34be0fe5c18f0d1c516d8 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Tue, 23 Mar 2021 13:51:32 +0700 Subject: [PATCH 02/25] Add is_digital attribute to listing, inventory only get method --- lib/etsy/inventory.rb | 4 ++-- lib/etsy/listing.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/etsy/inventory.rb b/lib/etsy/inventory.rb index 7ed813d..ff0e7f2 100644 --- a/lib/etsy/inventory.rb +++ b/lib/etsy/inventory.rb @@ -3,8 +3,8 @@ class Inventory include Etsy::Model attributes :products, :price_on_property, :quantity_on_property, :sku_on_property - def self.find_all_by_listing_id(listing_id, options={}) - get_all("/listings/#{listing_id}/inventory", options) + def self.find_by_listing_id(listing_id, options={}) + get("/listings/#{listing_id}/inventory", options) end private diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index 00ee12e..2e34f51 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -50,7 +50,7 @@ class Listing :shipping_template_id, :who_made, :when_made, :style, :category_path, :taxonomy_id, :taxonomy_attributes, :sku, :category_id, :taxonomy_path, - :has_variations, :should_auto_renew + :has_variations, :should_auto_renew, :is_digital association :image, :from => 'Images' @@ -59,7 +59,7 @@ def transactions end def inventory - Inventory.find_all_by_listing_id(id, oauth) + Inventory.find_by_listing_id(id, oauth) end def receipts From 09667d22988375591a7c651e638b3f5773d15ef0 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Tue, 23 Mar 2021 14:01:34 +0700 Subject: [PATCH 03/25] Update version --- lib/etsy/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 7bd1f88..9c66a2b 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.3" + VERSION = "0.3.4" end From 39f537866e34918a5fa2b6b146612f5de7b5e37a Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Tue, 23 Mar 2021 16:54:34 +0700 Subject: [PATCH 04/25] Add new attributes for receipt and transaction --- lib/etsy/receipt.rb | 4 +++- lib/etsy/transaction.rb | 2 +- lib/etsy/version.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/etsy/receipt.rb b/lib/etsy/receipt.rb index fb0c51b..88695e6 100644 --- a/lib/etsy/receipt.rb +++ b/lib/etsy/receipt.rb @@ -9,7 +9,9 @@ class Receipt attribute :last_modified, :from => :last_modified_tsz attributes :quantity, :listing_id, :name, :first_line, :second_line, :city, :state, :zip, :country_id, - :payment_email, :buyer_email + :formatted_address, :payment_method, :payment_email, :buyer_email, + :message_from_seller, :message_from_buyer, :was_paid, :was_shipped, + :grandtotal, :adjusted_grandtotal, :buyer_adjusted_grandtotal, :shipments def self.find(*identifiers_and_options) find_one_or_more('receipts', identifiers_and_options) diff --git a/lib/etsy/transaction.rb b/lib/etsy/transaction.rb index 11ee33d..b695dbe 100644 --- a/lib/etsy/transaction.rb +++ b/lib/etsy/transaction.rb @@ -15,7 +15,7 @@ class Transaction :tags, :materials, :image_listing_id, :receipt_id, :is_digital, :file_data, :listing_id, :url, :product_data, :variations, :transaction_type, :buyer_feedback_id, - :seller_feedback_id + :seller_feedback_id, :shipping_cost def self.find_all_by_shop_id(shop_id, options = {}) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 9c66a2b..32c60d6 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.4" + VERSION = "0.3.5" end From 06e014efd5580c1b4147124f47d5f40bc0316b67 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 27 Mar 2021 16:11:43 +0700 Subject: [PATCH 05/25] Add submit tracking code --- lib/etsy/receipt.rb | 5 +++++ lib/etsy/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/etsy/receipt.rb b/lib/etsy/receipt.rb index 88695e6..392582c 100644 --- a/lib/etsy/receipt.rb +++ b/lib/etsy/receipt.rb @@ -25,6 +25,11 @@ def self.find_all_by_shop_id_and_status(shop_id, status, options = {}) get_all("/shops/#{shop_id}/receipts/#{status}", options) end + def self.submit_tracking_by_shop_id(shop_id, receipt_id, options = {}) + options.merge!(:require_secure => true) + put("/shops/#{shop_id}/receipts/#{receipt_id}/tracking", options) + end + def created_at Time.at(created) end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 32c60d6..2934653 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.5" + VERSION = "0.3.6" end From b11b7c67a433ba148a800b3677e751a6e9a0b62c Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Thu, 8 Apr 2021 19:30:30 +0700 Subject: [PATCH 06/25] Add method for get all receipts and transaction. Not only 25 limit --- lib/etsy/listing.rb | 18 +++++++++++++----- lib/etsy/receipt.rb | 18 +++++++++++++----- lib/etsy/version.rb | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index 2e34f51..7cc59cf 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -58,12 +58,20 @@ def transactions @transactions ||= Transaction.find_all_by_listing_id(id, oauth) end + def all_transactions + @all_transactions ||= Transaction.find_all_by_listing_id(id, oauth.merge({ limit: :all })) + end + def inventory Inventory.find_by_listing_id(id, oauth) end def receipts - transactions.map{|t|t.receipt} + transactions.map(&:receipt) + end + + def all_receipts + all_transactions.map(&:receipt) end def self.create(options = {}) @@ -250,7 +258,7 @@ def ending_at def admirers(options = {}) options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) favorite_listings = FavoriteListing.find_all_listings_favored_by(id, options) - user_ids = favorite_listings.map {|f| f.user_id }.uniq + user_ids = favorite_listings.map(&:user_id).uniq (user_ids.size > 0) ? Array(Etsy::User.find(user_ids, options)) : [] end @@ -272,7 +280,7 @@ def self.sold_listings(shop_id, options = {}) includes = options.delete(:includes) transactions = Transaction.find_all_by_shop_id(shop_id, options) - listing_ids = transactions.map {|t| t.listing_id }.uniq + listing_ids = transactions.map(&:listing_id).uniq options = options.merge(:includes => includes) if includes (listing_ids.size > 0) ? Array(find(listing_ids, options)) : [] @@ -282,7 +290,7 @@ def self.sold_listings(shop_id, options = {}) # def self.find_all_user_favorite_listings(user_id, options = {}) favorite_listings = FavoriteListing.find_all_user_favorite_listings(user_id, options) - listing_ids = favorite_listings.map {|f| f.listing_id }.uniq + listing_ids = favorite_listings.map(&:listing_id).uniq (listing_ids.size > 0) ? Array(find(listing_ids, options)) : [] end @@ -292,7 +300,7 @@ def self.bought_listings(user_id, options = {}) includes = options.delete(:includes) transactions = Transaction.find_all_by_buyer_id(user_id, options) - listing_ids = transactions.map {|t| t.listing_id }.uniq + listing_ids = transactions.map(&:listing_id).uniq options = options.merge(:includes => includes) if includes (listing_ids.size > 0) ? Array(find(listing_ids, options)) : [] diff --git a/lib/etsy/receipt.rb b/lib/etsy/receipt.rb index 88695e6..396d88e 100644 --- a/lib/etsy/receipt.rb +++ b/lib/etsy/receipt.rb @@ -2,11 +2,11 @@ module Etsy class Receipt include Model - attribute :id, :from => :receipt_id - attribute :buyer_id, :from => :buyer_user_id + attribute :id, from: :receipt_id + attribute :buyer_id, from: :buyer_user_id - attribute :created, :from => :creation_tsz - attribute :last_modified, :from => :last_modified_tsz + attribute :created, from: :creation_tsz + attribute :last_modified, from: :last_modified_tsz attributes :quantity, :listing_id, :name, :first_line, :second_line, :city, :state, :zip, :country_id, :formatted_address, :payment_method, :payment_email, :buyer_email, @@ -36,11 +36,19 @@ def buyer def transactions unless @transactions options = {} - options = options.merge(:access_token => token, :access_secret => secret) if (token && secret) + options = options.merge(access_token: token, access_secret: secret) if token && secret @transactions = Transaction.find_all_by_receipt_id(id, options) end @transactions end + def all_transactions + unless @all_transactions + options = {} + options = options.merge(access_token: token, access_secret: secret) if token && secret + @all_transactions = Transaction.find_all_by_receipt_id(id, options.merge({ limit: :all })) + end + @all_transactions + end end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 32c60d6..2934653 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.5" + VERSION = "0.3.6" end From ec31a9b49db98c72f78b0b089387ece179f1c71f Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Thu, 8 Apr 2021 19:32:17 +0700 Subject: [PATCH 07/25] Add method for get all receipts and transaction. Not only 25 limit --- lib/etsy/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 2934653..4ecd70c 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.6" + VERSION = "0.3.7" end From 483c88f5b222b04d75fab2e9a2d4c942b2b58bea Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 11 Apr 2021 16:59:24 +0700 Subject: [PATCH 08/25] Correct post method for submitTracking --- lib/etsy/receipt.rb | 2 +- lib/etsy/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/etsy/receipt.rb b/lib/etsy/receipt.rb index 696333c..6503241 100644 --- a/lib/etsy/receipt.rb +++ b/lib/etsy/receipt.rb @@ -27,7 +27,7 @@ def self.find_all_by_shop_id_and_status(shop_id, status, options = {}) def self.submit_tracking_by_shop_id(shop_id, receipt_id, options = {}) options.merge!(:require_secure => true) - put("/shops/#{shop_id}/receipts/#{receipt_id}/tracking", options) + post("/shops/#{shop_id}/receipts/#{receipt_id}/tracking", options) end def created_at diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 4ecd70c..9854b08 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.7" + VERSION = "0.3.8" end From a8eb5676c271556167abcf5b33556f8186d04148 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Tue, 20 Apr 2021 10:54:23 +0700 Subject: [PATCH 09/25] Add Update inventory function --- lib/etsy/inventory.rb | 5 +++++ lib/etsy/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/etsy/inventory.rb b/lib/etsy/inventory.rb index ff0e7f2..25ee1bc 100644 --- a/lib/etsy/inventory.rb +++ b/lib/etsy/inventory.rb @@ -7,6 +7,11 @@ def self.find_by_listing_id(listing_id, options={}) get("/listings/#{listing_id}/inventory", options) end + def self.update_inventory(listing_id, options={}) + options.merge!(:require_secure => true) + put("/listings/#{listing_id}/inventory", options) + end + private def oauth diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 9854b08..0d407ff 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.8" + VERSION = "0.3.9" end From b1d707f3e1b9259a65ea7d1846001f949538b263 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 24 Apr 2021 09:12:08 +0700 Subject: [PATCH 10/25] Add taxonomy model TODO: Need update parent, children, fullpath --- lib/etsy/taxonomy.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/etsy/taxonomy.rb diff --git a/lib/etsy/taxonomy.rb b/lib/etsy/taxonomy.rb new file mode 100644 index 0000000..5d9a39a --- /dev/null +++ b/lib/etsy/taxonomy.rb @@ -0,0 +1,20 @@ +module Etsy + class Taxonomy + include Etsy::Model + + attribute :id + attributes :level, :name, :parent, :parent_id, :path, :category_id, :children, :children_ids, :full_path_taxonomy_ids + + def get_buyer_taxonomy + get('/taxonomy/buyer/get') + end + + def get_seller_taxonomy + get('/taxonomy/seller/get') + end + + def get_seller_taxonomy_version + get('/taxonomy/seller/version') + end + end +end \ No newline at end of file From 57fa408a3b042d5a27e54842792d8b0745fa401a Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 24 Apr 2021 09:12:54 +0700 Subject: [PATCH 11/25] Update version --- lib/etsy/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 0d407ff..9635f51 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.9" + VERSION = "0.3.10" end From 1659474950173dcee4622bd04fadc96e66dfef09 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 24 Apr 2021 15:32:44 +0700 Subject: [PATCH 12/25] Update version --- lib/etsy/taxonomy.rb | 6 +++--- lib/etsy/version.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/etsy/taxonomy.rb b/lib/etsy/taxonomy.rb index 5d9a39a..5fc2a66 100644 --- a/lib/etsy/taxonomy.rb +++ b/lib/etsy/taxonomy.rb @@ -5,15 +5,15 @@ class Taxonomy attribute :id attributes :level, :name, :parent, :parent_id, :path, :category_id, :children, :children_ids, :full_path_taxonomy_ids - def get_buyer_taxonomy + def self.get_buyer_taxonomy get('/taxonomy/buyer/get') end - def get_seller_taxonomy + def self.get_seller_taxonomy get('/taxonomy/seller/get') end - def get_seller_taxonomy_version + def self.get_seller_taxonomy_version get('/taxonomy/seller/version') end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 9635f51..e52655a 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.10" + VERSION = "0.3.11" end From 05eb41f54bd8d700559d9efd51c0f48edc893165 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 24 Apr 2021 16:06:55 +0700 Subject: [PATCH 13/25] Update taxonomy --- lib/etsy/taxonomy.rb | 4 ++-- lib/etsy/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/etsy/taxonomy.rb b/lib/etsy/taxonomy.rb index 5fc2a66..9d3d661 100644 --- a/lib/etsy/taxonomy.rb +++ b/lib/etsy/taxonomy.rb @@ -6,11 +6,11 @@ class Taxonomy attributes :level, :name, :parent, :parent_id, :path, :category_id, :children, :children_ids, :full_path_taxonomy_ids def self.get_buyer_taxonomy - get('/taxonomy/buyer/get') + get_all('/taxonomy/buyer/get') end def self.get_seller_taxonomy - get('/taxonomy/seller/get') + get_all('/taxonomy/seller/get') end def self.get_seller_taxonomy_version diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index e52655a..07e7a2d 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.11" + VERSION = "0.3.12" end From 73f51ee480e282e4b730ab8df7cc7c8a3ac237d7 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 24 Apr 2021 16:16:29 +0700 Subject: [PATCH 14/25] Update category --- lib/etsy/category.rb | 80 +++++--------------------------------------- lib/etsy/version.rb | 2 +- 2 files changed, 9 insertions(+), 73 deletions(-) diff --git a/lib/etsy/category.rb b/lib/etsy/category.rb index cf1a065..d61bc61 100644 --- a/lib/etsy/category.rb +++ b/lib/etsy/category.rb @@ -1,84 +1,20 @@ module Etsy - - # = Category - # - # A category of listings for sale, formed from 1 to 3 tags. - # - # A category has the following attributes: - # - # [page_description] A short description of the category from the category's landing page - # [page_title] The title of the category's landing page - # [category_name] The category's string ID - # [short_name] A short display name for the category - # [long_name] A longer display name for the category - # [children_count] The number of subcategories below this one - # class Category - include Etsy::Model - attribute :id, :from => :category_id - attribute :children_count, :from => :num_children - attributes :page_description, :page_title, :category_name, :short_name, - :long_name - - # Retrieve one or more top-level categories by name: - # - # Etsy::Category.find('accessories') - # - # You can find multiple top-level categories by passing an array of identifiers: - # - # Etsy::Category.find(['accessories', 'art']) - # - def self.find_top(*identifiers_and_options) - self.find_one_or_more('categories', identifiers_and_options) - end - - # Retrieve a list of all subcategories of the specified category. - # - # Etsy::Category.find_all_subcategories('accessories') - # - # You can also find the subcategories of a subcategory. - # - # Etsy::Category.find_all_subcategories('accessories/apron') - # - # Etsy categories only go three levels deep, so this will return nil past the third level. - # - # Etsy::Category.find_all_subcategories('accessories/apron/women') - # => nil - # - def self.find_all_subcategories(category, options = {}) - valid?(category) ? self.get_all("/taxonomy/categories/#{category}", options) : nil - end + attribute :id + attributes :level, :name, :parent, :parent_id, :path, :category_id, :children, :children_ids, :full_path_taxonomy_ids - def self.find(tag) - get("/categories/#{tag}") + def self.get_buyer_taxonomy + get_all('/taxonomy/buyer/get') end - # Retrieve a list of all top-level categories. - # - # Etsy::Category.all - # - def self.all_top(options = {}) - self.get_all("/taxonomy/categories", options) + def self.get_seller_taxonomy + get_all('/taxonomy/seller/get') end - # The collection of active listings associated with this category. - # - def active_listings - @active_listings ||= Listing.find_all_active_by_category(category_name) - end - - # The collection of subcategories associated with this category. - # - def subcategories - @subcategories ||= Category.find_all_subcategories(category_name) - end - - private - - def self.valid?(parent_category) - parent_category.count("/") < 2 + def self.get_seller_taxonomy_version + get('/taxonomy/seller/version') end end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 07e7a2d..9c717a9 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.12" + VERSION = "0.3.12.1" end From 673a391600df75b4c1f69919d863eb2b1401502e Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Wed, 28 Apr 2021 10:51:11 +0700 Subject: [PATCH 15/25] Add taxonomy_node_property --- lib/etsy/category.rb | 8 ++++++++ lib/etsy/version.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/etsy/category.rb b/lib/etsy/category.rb index d61bc61..c78bfcf 100644 --- a/lib/etsy/category.rb +++ b/lib/etsy/category.rb @@ -16,5 +16,13 @@ def self.get_seller_taxonomy def self.get_seller_taxonomy_version get('/taxonomy/seller/version') end + + def taxonomy_node_property + get_all("/taxonomy/seller/#{id}/properties") + end + + def self.taxonomy_node_property(taxonomy_id) + get_all("/taxonomy/seller/#{taxonomy_id}/properties") + end end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 9c717a9..535b6c7 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.12.1" + VERSION = "0.3.12.2" end From 86dcaa5bb8faaac0aae79d272cfc7a599a6edcb4 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 8 May 2021 16:00:35 +0700 Subject: [PATCH 16/25] Support create shop section --- lib/etsy/section.rb | 4 ++++ lib/etsy/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/etsy/section.rb b/lib/etsy/section.rb index b31afe1..a2f4779 100644 --- a/lib/etsy/section.rb +++ b/lib/etsy/section.rb @@ -12,5 +12,9 @@ def self.find_by_shop(shop) def self.find(shop, id) get("/shops/#{shop.id}/sections/#{id}") end + + def self.create(shop, options) + post("/shops/#{shop.id}/sections", options) + end end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 535b6c7..b863f86 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.12.2" + VERSION = "0.3.13" end From 02c793afef05bd967c60694a33103055f9cadf0c Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 10:12:29 +0700 Subject: [PATCH 17/25] Support ListingFile --- lib/etsy/listing_file.rb | 26 ++++++++++++++++++++++++++ lib/etsy/version.rb | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 lib/etsy/listing_file.rb diff --git a/lib/etsy/listing_file.rb b/lib/etsy/listing_file.rb new file mode 100644 index 0000000..9159183 --- /dev/null +++ b/lib/etsy/listing_file.rb @@ -0,0 +1,26 @@ +module Etsy + class ListingFile + include Etsy::Model + + attribute :id, :from => :listing_file_id + attribute :listing_id + + attributes :rank, :filename, :filesize, :size_bytes, :filetype, :create_date + + def find_files_by_listing(listing_id, options) + get_all("/listings/#{listing_id}/files", options) + end + + def upload_listing_file(listing_id, options) + post("/listings/#{listing_id}/files", options) + end + + def find_listing_file(listing_id, listing_file_id, options) + get("/listings/#{listing_id}/files/#{listing_file_id}", options) + end + + def delete_listing_file(listing_id, listing_file_id, options) + delete("/listings/#{listing_id}/files/#{listing_file_id}", options) + end + end +end \ No newline at end of file diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index b863f86..b7d7281 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.13" + VERSION = "0.3.14" end From 7aa164df6773168f3f77835c7e6aed917e209e37 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 10:19:33 +0700 Subject: [PATCH 18/25] Keep old homepage --- etsy.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etsy.gemspec b/etsy.gemspec index f37d571..52351e6 100644 --- a/etsy.gemspec +++ b/etsy.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| gem.email = ["reaganpr@gmail.com", "katrina.owen@gmail.com"] gem.description = %q{A friendly Ruby interface to the Etsy API} gem.summary = %q{Provides a friendly ruby-like wrapper for the Etsy API} - gem.homepage = "https://github.com/buithehien1991/etsy" + gem.homepage = "http://github.com/kytrinyx/etsy" gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } From 142e1564c4592ff89209545942f109648d7d9387 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 15:17:26 +0700 Subject: [PATCH 19/25] Correct static method for ListingFile --- lib/etsy/listing_file.rb | 8 ++++---- lib/etsy/version.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/etsy/listing_file.rb b/lib/etsy/listing_file.rb index 9159183..18d68ca 100644 --- a/lib/etsy/listing_file.rb +++ b/lib/etsy/listing_file.rb @@ -7,19 +7,19 @@ class ListingFile attributes :rank, :filename, :filesize, :size_bytes, :filetype, :create_date - def find_files_by_listing(listing_id, options) + def self.find_files_by_listing(listing_id, options) get_all("/listings/#{listing_id}/files", options) end - def upload_listing_file(listing_id, options) + def self.upload_listing_file(listing_id, options) post("/listings/#{listing_id}/files", options) end - def find_listing_file(listing_id, listing_file_id, options) + def self.find_listing_file(listing_id, listing_file_id, options) get("/listings/#{listing_id}/files/#{listing_file_id}", options) end - def delete_listing_file(listing_id, listing_file_id, options) + def self.delete_listing_file(listing_id, listing_file_id, options) delete("/listings/#{listing_id}/files/#{listing_file_id}", options) end end diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index b7d7281..457cc00 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14" + VERSION = "0.3.14.1" end From d72b042a36307aa8bb1777501b030c4fad3a837a Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 15:44:51 +0700 Subject: [PATCH 20/25] Dont know why happen error: NameError (uninitialized constant Etsy::ListingFile) --- lib/etsy/file.rb | 26 ++++++++++++++++++++++++++ lib/etsy/listing.rb | 4 ++++ lib/etsy/version.rb | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 lib/etsy/file.rb diff --git a/lib/etsy/file.rb b/lib/etsy/file.rb new file mode 100644 index 0000000..86021dc --- /dev/null +++ b/lib/etsy/file.rb @@ -0,0 +1,26 @@ +module Etsy + class File + include Etsy::Model + + attribute :id, :from => :listing_file_id + attribute :listing_id + + attributes :rank, :filename, :filesize, :size_bytes, :filetype, :create_date + + def self.find_files_by_listing(listing_id, options) + get_all("/listings/#{listing_id}/files", options) + end + + def self.upload_listing_file(listing_id, options) + post("/listings/#{listing_id}/files", options) + end + + def self.find_listing_file(listing_id, listing_file_id, options) + get("/listings/#{listing_id}/files/#{listing_file_id}", options) + end + + def self.delete_listing_file(listing_id, listing_file_id, options) + delete("/listings/#{listing_id}/files/#{listing_file_id}", options) + end + end +end \ No newline at end of file diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index 7cc59cf..8988f0f 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -146,6 +146,10 @@ def self.find_all_active_by_category(category, options = {}) get_all("/listings/active", options) end + def self.upload_listing_file(listing_id, options) + post("/listings/#{listing_id}/files", options) + end + # The collection of images associated with this listing. # def images diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 457cc00..3d88901 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14.1" + VERSION = "0.3.14.2" end From 516e5586d8663b6437ccec255f005c1c4c4dc443 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 15:48:02 +0700 Subject: [PATCH 21/25] Correct bug NameError (uninitialized constant Etsy::File) --- lib/etsy.rb | 2 ++ lib/etsy/file.rb | 26 -------------------------- lib/etsy/listing.rb | 4 ---- lib/etsy/version.rb | 2 +- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 lib/etsy/file.rb diff --git a/lib/etsy.rb b/lib/etsy.rb index 26a6f1c..0a9e42c 100644 --- a/lib/etsy.rb +++ b/lib/etsy.rb @@ -35,6 +35,8 @@ require 'etsy/variation/property_set' require 'etsy/about' require 'etsy/inventory' +require 'etsy/taxonomy' +require 'etsy/listing_file' # = Etsy: A friendly Ruby interface to the Etsy API # diff --git a/lib/etsy/file.rb b/lib/etsy/file.rb deleted file mode 100644 index 86021dc..0000000 --- a/lib/etsy/file.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Etsy - class File - include Etsy::Model - - attribute :id, :from => :listing_file_id - attribute :listing_id - - attributes :rank, :filename, :filesize, :size_bytes, :filetype, :create_date - - def self.find_files_by_listing(listing_id, options) - get_all("/listings/#{listing_id}/files", options) - end - - def self.upload_listing_file(listing_id, options) - post("/listings/#{listing_id}/files", options) - end - - def self.find_listing_file(listing_id, listing_file_id, options) - get("/listings/#{listing_id}/files/#{listing_file_id}", options) - end - - def self.delete_listing_file(listing_id, listing_file_id, options) - delete("/listings/#{listing_id}/files/#{listing_file_id}", options) - end - end -end \ No newline at end of file diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index 8988f0f..7cc59cf 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -146,10 +146,6 @@ def self.find_all_active_by_category(category, options = {}) get_all("/listings/active", options) end - def self.upload_listing_file(listing_id, options) - post("/listings/#{listing_id}/files", options) - end - # The collection of images associated with this listing. # def images diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 3d88901..5193f5c 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14.2" + VERSION = "0.3.14.3" end From fc23b9abd451881d2ade1f011a9b09c97db8c0fa Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 15:54:52 +0700 Subject: [PATCH 22/25] Add files method to listing --- lib/etsy/listing.rb | 4 ++++ lib/etsy/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/etsy/listing.rb b/lib/etsy/listing.rb index 7cc59cf..2cbabce 100644 --- a/lib/etsy/listing.rb +++ b/lib/etsy/listing.rb @@ -146,6 +146,10 @@ def self.find_all_active_by_category(category, options = {}) get_all("/listings/active", options) end + def files + @files ||= ListingFile.find_files_by_listing(id, oauth) + end + # The collection of images associated with this listing. # def images diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 5193f5c..96d0feb 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14.3" + VERSION = "0.3.14.4" end From 2a7a5edbd32406454d213a65f75ffdc161b4da11 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 19:16:33 +0700 Subject: [PATCH 23/25] Add update inventory post --- lib/etsy/inventory.rb | 5 +++++ lib/etsy/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/etsy/inventory.rb b/lib/etsy/inventory.rb index 25ee1bc..bddcf13 100644 --- a/lib/etsy/inventory.rb +++ b/lib/etsy/inventory.rb @@ -12,6 +12,11 @@ def self.update_inventory(listing_id, options={}) put("/listings/#{listing_id}/inventory", options) end + def self.update_inventory_post(listing_id, options={}) + options.merge!(:require_secure => true) + post("/listings/#{listing_id}/inventory", options) + end + private def oauth diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 96d0feb..81394fb 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14.4" + VERSION = "0.3.14.5" end From 66cc58b9ebce5d7e3540e56786ab0c59d22a48c4 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sun, 9 May 2021 22:04:41 +0700 Subject: [PATCH 24/25] Update inventory with put body data --- lib/etsy/inventory.rb | 2 +- lib/etsy/model.rb | 4 ++++ lib/etsy/request.rb | 9 +++++++++ lib/etsy/secure_client.rb | 14 ++++++++++++++ lib/etsy/version.rb | 2 +- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/etsy/inventory.rb b/lib/etsy/inventory.rb index bddcf13..cf45775 100644 --- a/lib/etsy/inventory.rb +++ b/lib/etsy/inventory.rb @@ -9,7 +9,7 @@ def self.find_by_listing_id(listing_id, options={}) def self.update_inventory(listing_id, options={}) options.merge!(:require_secure => true) - put("/listings/#{listing_id}/inventory", options) + put_body("/listings/#{listing_id}/inventory", options) end def self.update_inventory_post(listing_id, options={}) diff --git a/lib/etsy/model.rb b/lib/etsy/model.rb index 7236318..eec1120 100644 --- a/lib/etsy/model.rb +++ b/lib/etsy/model.rb @@ -84,6 +84,10 @@ def put(endpoint, options={}) Request.put(endpoint, options) end + def put_body(endpoint, options={}) + Request.put_body(endpoint, options) + end + def delete(endpoint, options={}) Request.delete(endpoint, options) end diff --git a/lib/etsy/request.rb b/lib/etsy/request.rb index 2abfd57..38dd958 100644 --- a/lib/etsy/request.rb +++ b/lib/etsy/request.rb @@ -22,6 +22,11 @@ def self.put(resource_path, parameters = {}) request = Request.new(resource_path, parameters) Response.new(request.put) end + + def self.put_body(resource_path, parameters = {}) + request = Request.new(resource_path, parameters) + Response.new(request.put_body) + end def self.delete(resource_path, parameters = {}) request = Request.new(resource_path, parameters) @@ -75,6 +80,10 @@ def post def put client.put(endpoint_url) end + + def put_body + client.put_body(endpoint_url(:include_query => false), @parameters) + end def delete client.delete(endpoint_url) diff --git a/lib/etsy/secure_client.rb b/lib/etsy/secure_client.rb index 34058c5..7edd25b 100644 --- a/lib/etsy/secure_client.rb +++ b/lib/etsy/secure_client.rb @@ -76,6 +76,20 @@ def post(endpoint) def put(endpoint) client.put(endpoint) end + + def put_body(endpoint, body) + # https = Net::HTTP.new(Etsy.host, Etsy.protocol == "http" ? 80 : 443) + # https.use_ssl = true if Etsy.protocol == "https" + # + # client.start do |http| + # req = Net::HTTP::Put.new(endpoint) + # add_oauth(req) + # req["Content-Type"] = "application/x-www-form-urlencoded" + # req.form_data = body + # res = http.request(req) + # end + client.put(endpoint, body, { 'Content-Type' => 'application/x-www-form-urlencoded' }) + end def delete(endpoint) client.delete(endpoint) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index 81394fb..abe13bc 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.14.5" + VERSION = "0.3.15" end From 0b2219352b01c5a4532b9c2d53efe7de0eca9277 Mon Sep 17 00:00:00 2001 From: Bui The Hien Date: Sat, 15 May 2021 20:39:51 +0700 Subject: [PATCH 25/25] Fix bug get all sections --- lib/etsy/section.rb | 2 +- lib/etsy/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/etsy/section.rb b/lib/etsy/section.rb index a2f4779..3810dc0 100644 --- a/lib/etsy/section.rb +++ b/lib/etsy/section.rb @@ -6,7 +6,7 @@ class Section attribute :id, :from => :shop_section_id def self.find_by_shop(shop) - get("/shops/#{shop.id}/sections") + get_all("/shops/#{shop.id}/sections") end def self.find(shop, id) diff --git a/lib/etsy/version.rb b/lib/etsy/version.rb index abe13bc..2d067e8 100644 --- a/lib/etsy/version.rb +++ b/lib/etsy/version.rb @@ -1,3 +1,3 @@ module Etsy - VERSION = "0.3.15" + VERSION = "0.3.15.1" end