GithubHelp home page GithubHelp logo

etsy's Introduction

Etsy

Build Status

Description

The Etsy gem provides a friendly Ruby interface to the Etsy API

Installation

Installing the latest stable version is simple:

$ gem install etsy

If you want to be on the bleeding edge, install from GitHub:

$ git clone git://github.com/iamfmjk/etsy.git
$ cd etsy
$ rake install

Dependencies

The gem has been verified to work with version 1.5.0 of json. It will likely work with higher versions, but this is unproven.

Usage

In order to try this out you'll need to create an app on etsy.com/your/apps.

This will give you an api key and secret.

Paste the following into IRB, replacing the api key and secret with the ones you got on Etsy:

require 'etsy'
Etsy.protocol = "https"
Etsy.api_key = 'YOUR API KEY'
Etsy.api_secret = 'YOUR SECRET'
request = Etsy.request_token
Etsy.verification_url

Paste the verification URL into your browser, and authorize the application. That will give you a page with a code on it. Paste the following into IRB, replacing the code:

access = Etsy.access_token(request.token, request.secret, 'CODE')
Etsy.myself(access.token, access.secret)

If you've received a 401 unauthorized error, then you likely don't have a valid api key and secret, or perhaps the verification url timed out.

Public Mode

The Etsy API has two modes: public, and authenticated. Public mode only requires an API key (available from http://developer.etsy.com ):

require 'etsy'

Etsy.api_key = 'foobar'

From there, you can make any non-authenticated calls to the API that you need.

Authenticated Calls

The Etsy API has support for both retrieval of extended information and write support for authenticated users. Authentication can either be performed from the console or from within a Ruby web application.

Console

For simple authentication from the console, configure the necessary parameters:

require 'etsy'

Etsy.api_key = 'key'
Etsy.api_secret = 'secret'

First, generate a request token:

request = Etsy.request_token

From there, you will need to paste a verification URL into a browser:

Etsy.verification_url

Once you have allowed access, you can generate an access token by supplying the verifier displayed on the Etsy site:

access = Etsy.access_token(request.token, request.secret, 'abc123')

Authenticated calls can now be made by passing an access token and secret:

Etsy.myself(access.token, access.secret)

The key and secret have to be passed in for the authenticated calls.

auth = {:access_token=>access.token, :access_secret=>access.secret}
Etsy::Transaction.find_all_by_shop_id(shop_id, auth.merge(options))

Web Application

The process for authenticating via a web application is similar, but requires the configuration of a callback URL:

require 'etsy'

Etsy.api_key = 'key'
Etsy.api_secret = 'secret'
Etsy.callback_url = 'http://localhost:4567/authorize'

In this mode, you'll need to store the request token and secret before redirecting to the verification URL. A simple example using Sinatra:

enable :sessions

get '/' do
  request_token = Etsy.request_token
  session[:request_token]  = request_token.token
  session[:request_secret] = request_token.secret
  redirect Etsy.verification_url
end

get '/authorize' do
  access_token = Etsy.access_token(
    session[:request_token],
    session[:request_secret],
    params[:oauth_verifier]
  )
  # access_token.token and access_token.secret can now be saved for future API calls
end

Environment

The Etsy API previously had both a sandbox environment and a production environment. They have recently eliminated the sandbox environment, but the ability to set the environment has been preserved in case it is implemented in v3.

If nothing is set, the default is :production.

You can set this using:

Etsy.environment = :production

Error handling

For legacy reasons, this gem does not raise errors when requests are unsuccessful. However, you can force errors to be thrown by configuring the silent_errors flag.

>>> Etsy.silent_errors = false

DSL

Use the Etsy::Request class to make flexible calls to the API.

To do so, find out which endpoint you wish to connect to and the parameters you wish to pass in.

>> access = {:access_token => 'token', :access_secret => 'secret'}
>> Etsy::Request.get('/taxonomy/tags', access.merge(:limit => 5))

or to fetch an associated resource

>> access = {:access_token => 'token', :access_secret => 'secret'}
>> Etsy::Request.get('/users/__SELF__', access.merge(:includes => 'Profile'))

or to limit the fields returned

>> shop_id = 'littletjane'
>> access = {:access_token => 'token', :access_secret => 'secret'}
>> Etsy::Request.get('/shops/#{shop_id}', access.merge(:fields => 'is_vacation,is_refusing_alchemy'))

Convenience Methods

There are some wrappers for resources that typically are needed in a small application.

Users

If you're starting with a user, the easiest way is to use the Etsy.user method:

>> user = Etsy.user('littletjane')
=> #<Etsy::User:0x107f82c @result=[{"city"=>"Washington, DC", ... >
>> user.username
=> "littletjane"
>> user.id
=> 5327518

For more information about what is available for a user, check out the documentation for Etsy::User.

Shops

Each user may optionally have a shop. If a user is a seller, he / she also has an associated shop object:

>> shop = user.shop
=> #<Etsy::Shop:0x102578c @result={"is_vacation"=>"", "announcement"=> ... >
>> shop.name
=> "littletjane"
>> shop.title
=> "a cute and crafty mix of handmade goods."

More information about shops can be found in the documentation for Etsy::Shop.

Listings

Shops contain multiple listings:

>> shop.listings
=> [#<Etsy::Listing:0x119acac @result={} ...>, ... ]
>> listing = shop.listings.first
=> #<Etsy::Listing:0x19a981c @result={} ... >
>> listing.title
=> "hanging with the bad boys matchbox"
>> listing.description
=> "standard size matchbox, approx. 1.5 x 2 inches ..."
>> listing.url
=> "http://www.etsy.com/view_listing.php?listing_id=24165902"
>> listing.view_count
=> 19
>> listing.created_at
=> Sat Apr 25 11:31:34 -0400 2009

See the documentation for Etsy::Listing for more information.

Images

Each listing has one or more images available:

>> listing.images
=> [#<Etsy::Image:0x18f85e4 @result={} ... >,
  #<Etsy::Image:0x18f85d0 @result={} ... >]
>> listing.images.first.square
=> "http://ny-image0.etsy.com/il_75x75.189111072.jpg"
>> listing.images.first.full
=> "http://ny-image0.etsy.com/il_fullxfull.189111072.jpg"

Listings also have a primary image:

>> listing.image
=> #<Etsy::Image:0x18c3060 @result={} ... >
>> listing.image.full
=> "http://ny-image0.etsy.com/il_fullxfull.189111072.jpg"

More information is available in the documentation for Etsy::Image.

Associations

Associations on resources can be specified with the 'includes' key.

A single resource can be specified with the name of the resource as a string:

>> Listing.find(1, {:includes => 'Images'})

Multiple resources can be specified with the name of the resources as a comma-delimited string:

>> User.find(1, {:includes => ['FeedbackAsBuyer', 'FeedbackAsSeller']})

If you want a more fine-grained response, you can specify the associations as an array of hashes, each of which must contain the name of the resource, and can also include the fields you wish returned, as well as the limit and offset.

>> association = {:resource => 'Images', :fields => ['red','green','blue'], :limit => 1, :offset => 0}
>> Listing.find(1, {:includes => [association]})

Public mode vs authenticated calls

This additional example should make clear the difference between issuing public versus authenticated requests:

Public workflow

>> Etsy.api_key = 'key'
>> user = Etsy.user('user_id_or_name')
>> Etsy::Listing.find_all_by_shop_id(user.shop.id, :limit => 5)

Authenticated workflow

>> Etsy.api_key = 'key'
>> Etsy.api_secret = 'secret'
>> user = Etsy.myself(token, secret)
>> access = { :access_token => user.token, :access_secret => user.secret }
>> Etsy::Listing.find_all_by_shop_id(user.shop.id, access.merge(:limit => 5))

Contributing

I have a "commit bit" policy for contributions to this repository. Once I accept your patch, I will give you full commit access. To submit patches:

  1. Fork this repository
  2. Implement the desired feature with tests (and documentation if necessary)
  3. Send me a pull request

I ask that you not submit patches that include changes to the version or gemspec.

Basics steps for contributing using (https://github.com/defunkt/hub)

# Setup the project
git clone kytrinyx/etsy
git fork
bundle
rake

# Normal flow
git checkout -b your-feature-or-bug
# Write your tests
# Make the tests pass
git add <CHANGES>
git commit -m "Some useful message"
git push -u YOUR-GITHUB-USERNAME your-feature-or-bug
git pull-request

Contributors

These people have helped make the Etsy gem what it is today:

Github Flow

For those of you with commit access, please check out Scott Chacon's blog post about github flow

  • Anything in the master branch is deployable
  • To work on something new, create a descriptively named branch off of master (ie: new-oauth2-scopes)
  • Commit to that branch locally and regularly push your work to the same named branch on the server
  • When you need feedback or help, or you think the branch is ready for merging, open a pull request
  • After someone else has reviewed and signed off on the feature, you can merge it into master
  • Once it is merged and pushed to ‘master’, you can and should deploy immediately

License

The Etsy rubygem is released under the MIT license.

etsy's People

Contributors

cardmagic avatar danielsz avatar fbehrens avatar iamfmjk avatar irosenb avatar iyerushalmi avatar jakeboxer avatar jimmytang avatar johnamican avatar julio avatar justinjruby avatar jwachira avatar kirillplatonov avatar kytrinyx avatar magni- avatar mason-stewart avatar mateus-resende avatar mattrayner avatar mfields106 avatar muon avatar paxer avatar plainlystated avatar pupca avatar reagent avatar rogsmith avatar sgerrand avatar sheprograms avatar trobrock avatar williamcodes avatar zhaoguoyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etsy's Issues

Image API

Create and Destroy of Image API, require a listing as parameter, but actually it only need a listing_id.

If start with a existing listing, it is fine, but think about the following scenario:

  1. Create a new listing then the API won't return a listing, it only return the listing_id(with current API when this issue raising)
  2. For adding image to the newly created listing, you have to query the whole listing with the listing_id again
  3. Then using the Create Image API to add image

Suggestion:
Change Create and Destroy API to using listing_id, then it will work for both scenario.

Developers at Etsy?

We are having a massive issue with Etsy API at the moment, and their developer support is not responding.

Does anybody have any contacts at Etsy that they can send me? Any help would be appreciated.

Thanks guys!

How to get some user fields?

Hi to all...
I need to get such user field as city, but on typing:
>> user.city
get error:
NoMethodError: undefined method `city' for #Etsy::User:0xb6d2c2cc

There is how i get user:
>> user = Etsy.user('littletjane'))
=> #<Etsy::User:0xb6d3df90 @result={"referred_by_user_id"=>nil, "login_name"=>"littletjane", "user_id"=>5327518, "creation_tsz"=>1191381578, "feedback_info"=>{"count"=>501, "score"=>100}}>

also method seller? doesen't work...
>> user.seller?
give me error:
NoMethodError: undefined method `seller?' for #Etsy::User:0xb6d2c2cc

What i'm doing wrong?
Thx...

rubygems.org out of date

The latest version of the gem on rubygems.org is 0.2.7, and does not support fetching listings of shops over 25 items. the latest version (on github) seems to be 1.8.10. Is there a reason that rubygems.org isn't up to date?

Listing.find_all_by_shop_id() throws error with state=sold

Listing.find_all_by_shop_id() is throwing Etsy::EtsyJSONInvalid when the state is set to sold.

Example:

access = { :access_token => 'mytoken', :access_secret => 'mysecret' }
listings = Etsy::Listing.find_all_by_shop_id(myshop_id, access.merge(:state => :sold, :limit => 100, :offset => 0))

All other valid states (active, inactive, expired, featured) work as expected.

Etsy client not usable thread-safely with multiple API keys

Using multiple API credentials with the client is currently impossible to do thread-safely since everything is in the global module. I propose creating an Etsy::Client class, like the Twitter gem's Twitter::Client. This would permit creating separate instances of it for the multi-key use case, and an instance of it could be stuffed in the module to keep backwards compatibility.

404 Bad Request Response in all Oauth API requests

Etsy people enforced secure api request under openapi subdomain (details here).

The current released gem v.0.2.2 uses http only as you can see here

I was looking at the code in order to fix this, and it looks like there is a fix already for it (it was made on #64), any plans to make a new release on rubygems?

Historic sales data?

Can the gem be used to retrieve historic sales data and transaction information for an authorized user's shop?

Is anyone working on updates for new version of API?

Etsy is pushing out a brand new version of their API in early February. Is anyone working on amending this gem so that it is compatible with the new version? I do not want to reinvent the wheel if the work is already being done. Otherwise I will begin working on adjustments ASAP

Multilanguage support

Hi everyone,
Etsy recently enabled support for Russian language (as I know other languages are available as well). Is there the way to get shop items in different languages?

Regards,
Dmitry

400 Error on New Listing

I am getting a 400 error when trying to create a new listing:

        @listing = Etsy::Listing.create(@access.merge(
            title: "test",
            description: "test description",
            quantity: 10,
            price: 5.5,
            who_made: "someone_else",
            is_supply: true,
            when_made: "before_1997",
            state: "draft",
            shipping_template_id: 12605497
        ))

Any idea why this might be? I am able to successfully make other API calls...

Etsy.access_token 500's in :sandbox

I'm trying to get OAuth set up per the instructions in the README, but when I get to:

access = Etsy.access_token(request.token, request.secret, 'my_verification_code')

I get a a 500. I have tried with ruby 1.9.2 and 1.8.7. I am using the latest github version.

1.8.7 :003 > access = Etsy.access_token(request.token, request.secret, "1fac4eee")
Net::HTTPFatalError: 500 "Server Error"
from /Users/rellik/.rvm/rubies/ruby-1.8.7-p357/lib/ruby/1.8/net/http.rb:2105:in error!' from /Users/rellik/.rvm/gems/ruby-1.8.7-p357@etsy/gems/oauth-0.4.5/lib/oauth/consumer.rb:221:intoken_request'
from /Users/rellik/.rvm/gems/ruby-1.8.7-p357@etsy/gems/oauth-0.4.5/lib/oauth/tokens/request_token.rb:18:in get_access_token' from ./lib/etsy/secure_client.rb:55:inclient_from_request_data'
from ./lib/etsy/secure_client.rb:63:in client' from ./lib/etsy.rb:133:inaccess_token'
from (irb):3

Listings die when store has a single listing

When iterating over the listings returned on a store with a single listing, the listings are broken up into as many listing objects as attributes. I.e., if a listing has 30 attributes, you'll receive 30 listings with a single attribute.

When gettting shop listings variations are empty

Hi,

When trying to get the shop listings and looping over them, each listing has the property
has_variations = true,
yet the array listing.variations remains empty
I couldn't find a way to force the fetching of this association, yet other associations like images do get pulled.
Pulling the single listing on its own by Id and requesting the association, the variations are populated:
listing = Etsy::Listing.find(listing.id, {:includes => 'Variations'})
However I don't want to fetch each listing independently, which would be awfully bad performance.

Thanks
Amit

Documentation Request!

Hey guys!

I just went through a huge debacle with Etsy and my own site because I was doing custom requests the wrong way. I'm not sure where it all started, but I was making requests like:

Etsy::Request.get("/users/:shop_id/charges", access.merge(:shop_id => @shop))

Where I ought to have been calling it as:

Etsy::Request.get("/users/#{@shop}/charges", access)

Etsy's documentation is not formatted well and I completely missed the section describing that it has to work like the latter, and their recent update made it so the former type of call doesn't work at all.

I was just thinking it'd be helpful to append the Custom Request section of the readme to explain that you need to substitute the :variable in your URL's with the actual variable. What do you guys think? Helpful?

Allow for "single user" mode

Allow the setting of Etsy.access_token and Etsy.access_secret to be passed on all calls to allow simplified use by a single user.

cannot generate request token

We are using the rubygems version of the gem, not the github version, with Ruby v2.1.1. We get an OpenSSL error. I've changed them in this issue for obvious reasons but the real api key and secret work using PostMan and HTTParty.

irb(main):002:0> Etsy.api_key = 'x03ho6jzhg4g7m5obqqqwer134kad'
=> "xertuy67ihg4g7m5oq4rq345d"
irb(main):003:0> Etsy.api_secret = 'kt5p1gbe02'
=> "kt5p1gbe02"
irb(main):004:0> request = Etsy.request_token
OpenSSL::SSL::SSLError: hostname does not match the server certificate
from /usr/lib/ruby/1.9.1/openssl/ssl-internal.rb:129:in post_connection_check' from /usr/lib/ruby/1.9.1/net/http.rb:801:inconnect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in do_start' from /usr/lib/ruby/1.9.1/net/http.rb:744:instart'
from /usr/lib/ruby/1.9.1/net/http.rb:1284:in request' from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/oauth-0.4.7/lib/oauth/consumer.rb:161:inrequest'
from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/oauth-0.4.7/lib/oauth/consumer.rb:194:in token_request' from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/oauth-0.4.7/lib/oauth/consumer.rb:136:inget_request_token'
from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/etsy-0.2.6/lib/etsy/secure_client.rb:36:in request_token' from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/etsy-0.2.6/lib/etsy/verification_request.rb:13:inrequest_token'
from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/etsy-0.2.6/lib/etsy.rb:151:in request_token' from (irb):4 from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/railties-4.1.0.rc2/lib/rails/commands/console.rb:90:instart'
from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/railties-4.1.0.rc2/lib/rails/commands/console.rb:9:in start' from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/railties-4.1.0.rc2/lib/rails/commands/commands_tasks.rb:69:inconsole'
from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/railties-4.1.0.rc2/lib/rails/commands/commands_tasks.rb:40:in run_command!' from /home/flatiron/recommendsy/shared/bundle/ruby/1.9.1/gems/railties-4.1.0.rc2/lib/rails/commands.rb:17:in<top (required)>'
from bin/rails:8:in require' from bin/rails:8:in

'irb(main):005:0>

Can't get associated fields

So the point is getiing user profile fields, but executing next:

Etsy::Request.get('/users/SELF?includes=Profile', :access_token => @access_token.token, :access_secret => @access_token.secret)

Have an error:
HTTPBadRequest 400 Bad Request

@access_token getting from OAuth.

Btw if i want to get user:

Etsy::Request.get('/users/SELF', :access_token => @access_token.token, :access_secret => @access_token.secret)

It returns hash with some user fields.

Could't get __SELF__ response

I have tried doing oauth and tried fetching SELF i.e. Etsy.myself() but it gives me 400 bad request error. Though I tried with standalone request as well and still it gives error. So I have asked to etsy support team as well.

Thanks,
Anand Soni

Blow up loudly—don't silence errors

It's incredibly frustrating to get nil or empty responses when in reality the API complained quite specifically that the permissions were wrong given the scope of the token, or some such thing.

Very High Memory Usage

This gem uses up 18% of my system memory on a 4gb server... Still trying to decide if it's how my code is using the gem... or the gem itself. Has anybody seen spikes in memory usage from this gem? Most of our importing is done via Delayed Jobs.

Failed to upload image: 400 Bad Request

require 'etsy'
Etsy.silent_errors = false
Etsy.api_key='xxxx'
Etsy.api_secret='xxxx'
Etsy.protocol = 'https'
access = {:access_token => 'xxxx', :access_secret => 'xxxx'}
listing = Etsy::Listing.find(yyyy)
Etsy::Image.create(listing, 'C:/temp/test.jpg', access)

=> #<Etsy::Response:0x2e4b338 @raw_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>>

Other calling of api all works fine.

I debugged it, the body of raw_response said "please make sure both width and height are greater than 10px", but I am quite sure that test.jpg satisfy this condition.

Change to the BillCharge findAllUserCharges call

https://groups.google.com/forum/?fromgroups#!topic/etsy-api-v2/MUx0MJhRvTU

Hi everyone,

To improve the response speed for API calls to BillCharge findAllUserCharges (/users/:user_id/charges) we are planning to alter the behaviour such that the min_created and max_created parameters become mandatory and can be no more than 31 days apart. If only one of these _created parameters is submitted in a request then the other will default to +/-31 days as appropriate.

http://www.etsy.com/developers/documentation/reference/billcharge#method_findallusercharges

As this is a behaviour change to this API call we intend to roll it out over the following timeline:

* 07/02/12, today: notify the API mailing list and add a note to this effect to the developer's documentation.
* 07/16/12, two weeks from now: monitor API requests and notify any developers relying on the old behavior.
* 07/25/12, three weeks from now: switch over to the new behavior, any requests that do not include min_created and max_created will be returned a HTTP 400 error response.

We realise that this might result in some additional work but hope you can appreciate that the current unrestricted approach slows down our response and, indirectly, your applications.

Cheers,

Paul.

Allow Listing.find_all_by_shop_id to filter based on listing state

There are a few API calls for listings that deal with state. Ideally, we would just pass a parameter to Listing.find_all_by_shop_id that would choose the right endpoint. The calls I see that this would apply to:

My thoughts around an implementation look like this:

Listing.find_all_by_shop_id(123, :status => 'expired')

Where the :status parameter can accept a value of active, expired, featured, or inactive -- for now we can have it default to active if it's not present.

Unable to get `myself`

Having obtained (and saved) the Etsy access_token and access_secret, I am trying to get Etsy.myself.
I am unable to however, as after passing in the :oauth_consumer_key, I get oauth_problem=signature_invalid.

Calling like this:

Etsy.myself "<my_access_token>","<my_access_secret>", :oauth_consumer_key => "<my_etsy_api_key>"

Getting this:

oauth_problem=signature_invalid
&amp;debug_sbs=GET
&amp;http://sandbox.openapi.etsy.com/v2/users/__SELF__
&amp;oauth_consumer_key=<my_api_key>
&amp;oauth_nonce=<some_random_string>
&amp;oauth_signature_method=HMAC-SHA1
&amp;oauth_timestamp=<some_time_stamp>
&amp;oauth_token=<my_access_token>
&amp;oauth_version=1.0  

Note that I am able to get a session like this:

session = Etsy::SecureClient.new :access_token => "<my_access_token>", :access_secret => "<my_access_secret>"

But if I try to get __SELF__:

session.get "/users/__SELF__"   

I get a 404 message: Not Found.

Is this a bug in the gem?

All Requests = '400 Bad Request' (or so it seems)

It seems that I get a '400 Bad Request' result for any request I try to make. Is something broken or am I missing something?

jeremiahs-mbp:jds jdm$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.0.0]

jeremiahs-mbp:jds jdm$ bundle show etsy
/Users/jdm/.rvm/gems/ruby-2.0.0-p353@e/gems/etsy-0.2.5

jeremiahs-mbp:jds jdm$ irb
2.0.0p353 :001 > require 'rubygems'
2.0.0p353 :002 > require 'etsy'
2.0.0p353 :003 > Etsy.api_key = '***********'
2.0.0p353 :004 > Etsy.api_secret = '************'
2.0.0p353 :011 > Etsy.environment = :production
2.0.0p353 :014 > request = Etsy.request_token
 => #<OAuth::RequestToken ... >

2.0.0p353 :015 > Etsy.verification_url
 => "https://www.etsy.com/oauth/ ... > 

2.0.0p353 :016 > access = Etsy.access_token request.token, request.secret, '5fc35f7b'
 => #<OAuth::AccessToken ... >

2.0.0p353 :018 > access = {access_token: access.token, access_secret: access.secret}

2.0.0p353 :027 > Etsy::Request.get('/shops/9RCSC', access)
 => #<Etsy::Response:0x007f9fa40bc160 @raw_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>>

2.0.0p353 :028 > Etsy::Request.get('/users/__SELF__', access)
 => #<Etsy::Response:0x007f9fa405fd70 @raw_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>>

Thanks, Jeremiah

Pagination in model.rb

What I am trying to do: Get all of the items in a resource (listings, orders, receipts, etc...) But It's always returning 100.

Here is what I noticed:

In https://github.com/kytrinyx/etsy/blob/master/lib/etsy/model.rb, line 46:

limit = [response.count - batch_size - initial_offset, 0].max

In this file:

https://github.com/kytrinyx/etsy/blob/master/lib/etsy/response.rb

Line 35-41:

def count
  if paginated?
    to_hash['results'].nil? ? 0 : to_hash['results'].size
  else
    to_hash['count']
  end
end

So ---- if there is pagination, it returns COUNT as the size of the results set. Doesn't that means in model.rb, LIMIT will always be <= 0, which means that when you do {:limit => :all}, you are not getting all, which defeats the whole purpose?

Am I missing something here?

In my app, I had to monkeypatch Etsy::Response.paginated? to return "false".

ShippingTemplate response is nil

I have set up my profile on etsy and a shop within the profile (in development mode). I also added a shipping profile within the shop. As I understand, this shipping profile is what would be returned if I try to find shippingtemplates associated with the user (I can't find a way to directly create a shipping profile for a user on Etsy website, it seems to be possible only within a shop).

But, I get a nil response for the shipping template (sequence below).

Am I doing something wrong?

2.1.2 :019 > user=Etsy.user('xxxx')
...
...
2.1.2 :019 > credentials = {:access_token=>"xxxx", :access_secret=>"xxxx"}
....
2.1.2 :020 > ship_template=Etsy::ShippingTemplate.find_by_user(user, credentials)
=> nil
2.1.2 :021 >

Thanks!

Responses never raise errors

Hi,

I would like to report a usability issue.
Calling result on a response will return an empty array if the request was not successful. I think it should raise an error instead.
You made excellent work defining error classes in the response class, why not use them?
This is what other api wrappers do, and for good reason. Consider this: the user revoked access. API consumers need to know when such a situation occurs. But they never will, they get an empty array instead of the error.
Recommendation: raise errors in the result method.
I'm making a basic pull request illustrating this.

Thanks!

Getting Listings for one section

Hi,

Thanks for writing this gem! :) Can you tell me how to get the Listings for a single section of a single shop? I have the section I want but can't figure out how to work with it...

https://www.etsy.com/developers/documentation/reference/listing#method_findallshopsectionlistings says I need to pass at least shop_id and shop_section_id - is the below the correct syntax for that? I'm hoping that I'm just missing something from *identifiers_and_options but I don't know what it is. Can you help?

irb(main):044:0> user.shop.id
=> 5308141

irb(main):045:0> sect
=> #<Etsy::Section:0x00000001af7728 @result={"shop_section_id"=>7794481, "title"=>"Cabochons", "rank"=>5, "user_id"=>5569833, "active_listing_count"=>15}, @token=nil, @secret=nil>

irb(main):046:0> Etsy::Listing.find({:shop_id => user.shop.id, :shop_section_id => sect})
Etsy::EtsyJSONInvalid: Etsy::EtsyJSONInvalid
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/response.rb:92:in `validate!'
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/response.rb:58:in `result'
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/model.rb:67:in `get_all'
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/model.rb:24:in `get'
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/model.rb:96:in `find_one_or_more'
    from /var/lib/gems/1.9.1/gems/etsy-0.3.0/lib/etsy/listing.rb:75:in `find'
    from (irb):46
    from /usr/bin/irb:12:in `<main>'

Cheers,
Gavin.

New gem push

With Etsy moving to HTTPS only api on March 17, should we push a new version of the gem @kytrinyx ?

CI is failing, jruby this time

I'm tempted to stick jruby on the "allowed failures" list. I suspect that if you're writing an etsy app, you're not deploying it on rubinius or jruby. It might be OK to deprecate support for these.

Grabbing results count

Hi, unless I am mistaken, it seems there is no way to grab the number of results in an API query. For example if we run a query on Listings, and call the count method it will only tell us how many listings are returned based on the limit, not the total number of results available. Is there any way to grab the total number of results available (i.e. a number greater than 250)?

OAuth not generating new request tokens!

Hey there!

I've been playing around with the gem quite a bit the last few days, and I've been having trouble getting it working in production for really only one reason – new request tokens weren't being issued. I'm realizing now it may not be just in production.

Person A would have no problem generating a request token, hitting allow & being taken to the callback, where I could save the access token, just like in the readme. But then Person B would come along, and it would be the exact some request token as Person A, so Etsy would say "sorry, that's been used already."

I thought at first it was because it was getting hung up on the fact that @request_token already existed, but I'm not sure.

class VerificationRequest # :nodoc:all
  def request_token
    @request_token ||= client.request_token
  end
end

I tested out what would happen with manually setting @request_token as false right before (and as a different test, right after), to force it to request a new token, but found that that just ended up with each person being connected to the last person's OAuth credentials. Not so good.

I'll keep trying stuff and seeing what I can find, do you guys have any ideas?

Gem won't work with rails 3.1.1 -- JSON version lock conflict

I'm having an issue getting the etsy gem to work with the rails 3.1.1
bundle install give the following result:

Bundler could not find compatible versions for gem "json":
  In Gemfile:
    rails (= 3.1.1) ruby depends on
      json (~> 1.4) ruby

json (1.1.0)

Depends on json 1.4.0

The latest version of json is 1.5.1. You should change your gemspec to support ">=1.4.0" instead of "~>1.4.0"

Shop name and user name do not have to be the same

I am getting an error with Etsy.myself(token, secret).shop giving an error of 'username' is not a valid shop name because my username is not the same as my shop name. Am I trying to access this correctly?

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Shop data for authorized user is nil

I've managed to authorize a user in the console, but the shop data that gets returned is all "", nil or 0. My shop has lots of sales, feedback and whatnot, but its all coming back empty. Could this be a json version problem?

Any help would be much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.