etsy 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/etsy.gemspec +1 -1
- data/lib/etsy.rb +5 -0
- data/lib/etsy/attribute_value.rb +46 -0
- data/lib/etsy/bill_charge.rb +31 -0
- data/lib/etsy/bill_payment.rb +28 -0
- data/lib/etsy/billing_overview.rb +18 -0
- data/lib/etsy/image.rb +2 -0
- data/lib/etsy/listing.rb +23 -1
- data/lib/etsy/model.rb +1 -1
- data/lib/etsy/receipt.rb +9 -2
- data/lib/etsy/shipping_info.rb +27 -0
- data/lib/etsy/shipping_template.rb +10 -1
- data/lib/etsy/transaction.rb +46 -1
- data/lib/etsy/user.rb +30 -0
- data/lib/etsy/version.rb +1 -1
- data/test/fixtures/attribute_value/findAllListingPropertyValues.json +44 -0
- data/test/fixtures/bill_charge/getBillCharge.json +1 -0
- data/test/fixtures/bill_payment/getBillPayment.json +1 -0
- data/test/fixtures/billing_overview/getBillingOverview.json +1 -0
- data/test/fixtures/shipping_info/getShippingInfo.json +1 -0
- data/test/test_helper.rb +0 -1
- data/test/unit/etsy/attribute_value_test.rb +67 -0
- data/test/unit/etsy/bill_charge_test.rb +24 -0
- data/test/unit/etsy/bill_payment_test.rb +24 -0
- data/test/unit/etsy/billing_overview_test.rb +20 -0
- data/test/unit/etsy/model_test.rb +4 -4
- data/test/unit/etsy/shipping_info_test.rb +24 -0
- data/test/unit/etsy/transaction_test.rb +1 -1
- metadata +32 -7
data/etsy.gemspec
CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |gem|
|
|
30
30
|
# on shoulda/context.rb:7
|
31
31
|
# But then when you load active_support, shoulda-context decides
|
32
32
|
# to load MiniTest
|
33
|
-
gem.add_development_dependency '
|
33
|
+
gem.add_development_dependency 'test-unit', "~>3.2.5"
|
34
34
|
end
|
data/lib/etsy.rb
CHANGED
@@ -15,8 +15,12 @@ require 'etsy/verification_request'
|
|
15
15
|
require 'etsy/model'
|
16
16
|
require 'etsy/user'
|
17
17
|
require 'etsy/profile'
|
18
|
+
require 'etsy/bill_charge'
|
19
|
+
require 'etsy/bill_payment'
|
20
|
+
require 'etsy/billing_overview'
|
18
21
|
require 'etsy/shop'
|
19
22
|
require 'etsy/listing'
|
23
|
+
require 'etsy/attribute_value'
|
20
24
|
require 'etsy/image'
|
21
25
|
require 'etsy/transaction'
|
22
26
|
require 'etsy/address'
|
@@ -24,6 +28,7 @@ require 'etsy/category'
|
|
24
28
|
require 'etsy/payment_template'
|
25
29
|
require 'etsy/country'
|
26
30
|
require 'etsy/shipping_template'
|
31
|
+
require 'etsy/shipping_info'
|
27
32
|
require 'etsy/section'
|
28
33
|
require 'etsy/favorite_listing'
|
29
34
|
require 'etsy/receipt'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Etsy
|
2
|
+
|
3
|
+
# = AttributeValue
|
4
|
+
#
|
5
|
+
# An attribute of a listing according to its taxonomy.
|
6
|
+
#
|
7
|
+
# An attribute has the following attributes:
|
8
|
+
#
|
9
|
+
# [property_id] (INT) The numeric ID of this property.
|
10
|
+
# [property_name] (STRING) The name of the property, in the requested locale language.
|
11
|
+
# [scale_id] (INT) The numeric ID of the scale (if any).
|
12
|
+
# [scale_name] (STRING) The label used to describe the chosen scale (if any).
|
13
|
+
# [value_ids] (Array(INT)) The numeric IDs of the values.
|
14
|
+
# [values] (Array(STRING)) The literal values of the value
|
15
|
+
class AttributeValue
|
16
|
+
|
17
|
+
include Etsy::Model
|
18
|
+
|
19
|
+
attribute :id, :from => :property_id
|
20
|
+
attributes :property_name, :scale_id, :scale_name, :value_ids,
|
21
|
+
:values
|
22
|
+
|
23
|
+
# Fetch all property_values for a given listing.
|
24
|
+
#
|
25
|
+
def self.find_all_by_listing_id(listing_id, options = {})
|
26
|
+
get_all("/listings/#{listing_id}/attributes", options)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Adds a new attribute_value to the listing given
|
30
|
+
#
|
31
|
+
def self.create(listing, property_hash, options = {})
|
32
|
+
property_id = property_hash[:property_id]
|
33
|
+
options.merge!(:require_secure => true)
|
34
|
+
options.merge!(property_hash)
|
35
|
+
put("/listings/#{listing.id}/attributes/#{property_id}", options)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delete attribute_value from listing
|
39
|
+
#
|
40
|
+
def self.destroy(listing, property_value, options = {})
|
41
|
+
options.merge!(:require_secure => true)
|
42
|
+
delete("/listings/#{listing.id}/attributes/#{property_value.id}", options)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Etsy
|
2
|
+
|
3
|
+
# = BillCharge
|
4
|
+
#
|
5
|
+
# Represents a charge to an Etsy member's account.
|
6
|
+
#
|
7
|
+
#
|
8
|
+
class BillCharge
|
9
|
+
|
10
|
+
include Etsy::Model
|
11
|
+
|
12
|
+
attribute :id, :from => :bill_charge_id
|
13
|
+
attribute :created, :from => :creation_tsz
|
14
|
+
attribute :last_modified, :from => :last_modified_tsz
|
15
|
+
|
16
|
+
attributes :type, :type_id, :user_id, :amount, :currency_code, :creation_month,
|
17
|
+
:creation_year
|
18
|
+
|
19
|
+
def self.find_all_by_user_id(user_id, options = {})
|
20
|
+
get_all("/users/#{user_id}/charges", options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def created_at
|
24
|
+
Time.at(created)
|
25
|
+
end
|
26
|
+
|
27
|
+
def last_modified_at
|
28
|
+
Time.at(last_modified)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Etsy
|
2
|
+
|
3
|
+
# = BillPayment
|
4
|
+
#
|
5
|
+
# Represents a user's Billing Payment.
|
6
|
+
#
|
7
|
+
#
|
8
|
+
class BillPayment
|
9
|
+
|
10
|
+
include Etsy::Model
|
11
|
+
|
12
|
+
attribute :id, :from => :bill_payment_id
|
13
|
+
attribute :created, :from => :creation_tsz
|
14
|
+
|
15
|
+
attributes :type, :type_id, :user_id, :amount, :currency_code, :creation_month,
|
16
|
+
:creation_year
|
17
|
+
|
18
|
+
def self.find_all_by_user_id(user_id, options = {})
|
19
|
+
get_all("/users/#{user_id}/payments", options)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Time that this listing was created
|
23
|
+
#
|
24
|
+
def created_at
|
25
|
+
Time.at(created)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Etsy
|
2
|
+
|
3
|
+
# = BillingOverview
|
4
|
+
#
|
5
|
+
# A user's account balance on Etsy.
|
6
|
+
#
|
7
|
+
class BillingOverview
|
8
|
+
|
9
|
+
include Etsy::Model
|
10
|
+
|
11
|
+
attributes :is_overdue, :overdue_balance, :balance_due, :total_balance, :currency_code, :date_due,
|
12
|
+
:creation_year
|
13
|
+
|
14
|
+
def self.find_all_by_user_id(user_id, options = {})
|
15
|
+
get_all("/users/#{user_id}/billing/overview", options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/etsy/image.rb
CHANGED
@@ -17,6 +17,8 @@ module Etsy
|
|
17
17
|
attribute :square, :from => :url_75x75
|
18
18
|
attribute :small, :from => :url_170x135
|
19
19
|
attribute :thumbnail, :from => :url_570xN
|
20
|
+
attribute :height, :from => :full_height
|
21
|
+
attribute :width, :from => :full_width
|
20
22
|
attribute :full, :from => :url_fullxfull
|
21
23
|
|
22
24
|
# Fetch all images for a given listing.
|
data/lib/etsy/listing.rb
CHANGED
@@ -38,18 +38,28 @@ module Etsy
|
|
38
38
|
attribute :id, :from => :listing_id
|
39
39
|
attribute :view_count, :from => :views
|
40
40
|
attribute :created, :from => :creation_tsz
|
41
|
+
attribute :original_created, :from => :original_creation_tsz
|
41
42
|
attribute :modified, :from => :last_modified_tsz
|
42
43
|
attribute :currency, :from => :currency_code
|
43
44
|
attribute :ending, :from => :ending_tsz
|
45
|
+
attribute :shop_section, :from => :shop_section_id
|
44
46
|
|
45
47
|
attributes :title, :description, :state, :url, :price, :quantity,
|
46
48
|
:tags, :materials, :hue, :saturation, :brightness, :is_black_and_white,
|
47
49
|
:featured_rank, :occasion, :num_favorers, :user_id,
|
48
50
|
:shipping_template_id, :who_made, :when_made,
|
49
|
-
:
|
51
|
+
:style, :category_path, :taxonomy_id, :taxonomy_attributes
|
50
52
|
|
51
53
|
association :image, :from => 'Images'
|
52
54
|
|
55
|
+
def transactions
|
56
|
+
@transactions ||= Transaction.find_all_by_listing_id(id, oauth)
|
57
|
+
end
|
58
|
+
|
59
|
+
def receipts
|
60
|
+
transactions.map{|t|t.receipt}
|
61
|
+
end
|
62
|
+
|
53
63
|
def self.create(options = {})
|
54
64
|
options.merge!(:require_secure => true)
|
55
65
|
post("/listings", options)
|
@@ -141,6 +151,13 @@ module Etsy
|
|
141
151
|
@category ||= Category.find(path)
|
142
152
|
end
|
143
153
|
|
154
|
+
# Returns the taxonomy defined attributes for the listing
|
155
|
+
#
|
156
|
+
def taxonomy_attributes(options={})
|
157
|
+
options.merge!(:require_secure => true)
|
158
|
+
self.class.get_all("/listings/#{id}/attributes", oauth.merge(options))
|
159
|
+
end
|
160
|
+
|
144
161
|
def variations(options={})
|
145
162
|
options.merge!(:require_secure => true)
|
146
163
|
self.class.get_all("/listings/#{id}/variations", oauth.merge(options))
|
@@ -205,6 +222,11 @@ module Etsy
|
|
205
222
|
Time.at(created)
|
206
223
|
end
|
207
224
|
|
225
|
+
# Time that this listing was originally created
|
226
|
+
def original_created_at
|
227
|
+
Time.at(original_created)
|
228
|
+
end
|
229
|
+
|
208
230
|
# Time that this listing was last modified
|
209
231
|
#
|
210
232
|
def modified_at
|
data/lib/etsy/model.rb
CHANGED
@@ -43,7 +43,7 @@ module Etsy
|
|
43
43
|
if limit == :all
|
44
44
|
response = Request.get(endpoint, options.merge(:limit => batch_size, :offset => initial_offset))
|
45
45
|
result << response.result
|
46
|
-
limit = [response.
|
46
|
+
limit = [response.total - batch_size - initial_offset, 0].max
|
47
47
|
initial_offset += batch_size
|
48
48
|
end
|
49
49
|
|
data/lib/etsy/receipt.rb
CHANGED
@@ -5,8 +5,15 @@ module Etsy
|
|
5
5
|
attribute :id, :from => :receipt_id
|
6
6
|
attribute :buyer_id, :from => :buyer_user_id
|
7
7
|
|
8
|
+
attribute :created, :from => :creation_tsz
|
9
|
+
attribute :last_modified, :from => :last_modified_tsz
|
10
|
+
|
8
11
|
attributes :quantity, :listing_id, :name, :first_line, :second_line, :city, :state, :zip, :country_id,
|
9
|
-
:payment_email, :buyer_email
|
12
|
+
:payment_email, :buyer_email
|
13
|
+
|
14
|
+
def self.find(*identifiers_and_options)
|
15
|
+
find_one_or_more('receipts', identifiers_and_options)
|
16
|
+
end
|
10
17
|
|
11
18
|
def self.find_all_by_shop_id(shop_id, options = {})
|
12
19
|
get_all("/shops/#{shop_id}/receipts", options)
|
@@ -17,7 +24,7 @@ module Etsy
|
|
17
24
|
end
|
18
25
|
|
19
26
|
def created_at
|
20
|
-
Time.at(
|
27
|
+
Time.at(created)
|
21
28
|
end
|
22
29
|
|
23
30
|
def buyer
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Etsy
|
2
|
+
class ShippingInfo
|
3
|
+
include Etsy::Model
|
4
|
+
|
5
|
+
attribute :id, :from => :shipping_info_id
|
6
|
+
|
7
|
+
attributes :origin_country_id, :destination_country_id, :currency_code, :primary_cost, :secondary_cost, :listing_id, :region_id, :origin_country_name, :destination_country_name
|
8
|
+
|
9
|
+
def self.find(id, credentials = {})
|
10
|
+
options = {
|
11
|
+
:access_token => credentials[:access_token],
|
12
|
+
:access_secret => credentials[:access_secret],
|
13
|
+
:require_secure => true
|
14
|
+
}
|
15
|
+
get("/shipping/info/#{id}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find_all_by_listing_id(listing_id, credentials = {})
|
19
|
+
options = {
|
20
|
+
:access_token => credentials[:access_token],
|
21
|
+
:access_secret => credentials[:access_secret],
|
22
|
+
:require_secure => true
|
23
|
+
}
|
24
|
+
get_all("/listings/#{listing_id}/shipping/info", options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -19,7 +19,16 @@ module Etsy
|
|
19
19
|
}
|
20
20
|
get("/shipping/templates/#{id}", options)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
|
+
def self.find_entries(id, credentials = {})
|
24
|
+
options = {
|
25
|
+
:access_token => credentials[:access_token],
|
26
|
+
:access_secret => credentials[:access_secret],
|
27
|
+
:require_secure => true
|
28
|
+
}
|
29
|
+
get("/shipping/templates/#{id}/entries", options)
|
30
|
+
end
|
31
|
+
|
23
32
|
def self.find_by_user(user, credentials = {})
|
24
33
|
options = {
|
25
34
|
:access_token => credentials[:access_token],
|
data/lib/etsy/transaction.rb
CHANGED
@@ -4,25 +4,70 @@ module Etsy
|
|
4
4
|
|
5
5
|
attribute :id, :from => :transaction_id
|
6
6
|
attribute :buyer_id, :from => :buyer_user_id
|
7
|
+
attribute :seller_id, :from => :seller_user_id
|
7
8
|
attributes :quantity, :listing_id
|
8
9
|
|
10
|
+
attribute :created, :from => :creation_tsz
|
11
|
+
attribute :shipped, :from => :shipped_tsz
|
12
|
+
attribute :paid, :from => :paid_tsz
|
13
|
+
|
14
|
+
attributes :title, :description, :price, :currency_code, :quantity,
|
15
|
+
:tags, :materials, :image_listing_id, :receipt_id,
|
16
|
+
:is_digital, :file_data, :listing_id, :url, :product_data,
|
17
|
+
:variations, :transaction_type, :buyer_feedback_id,
|
18
|
+
:seller_feedback_id
|
19
|
+
|
20
|
+
|
9
21
|
def self.find_all_by_shop_id(shop_id, options = {})
|
10
22
|
get_all("/shops/#{shop_id}/transactions", options)
|
11
23
|
end
|
12
24
|
|
25
|
+
def created_at
|
26
|
+
Time.at(created)
|
27
|
+
end
|
28
|
+
|
29
|
+
def shipped_at
|
30
|
+
Time.at(shipped)
|
31
|
+
end
|
32
|
+
|
33
|
+
def paid_at
|
34
|
+
Time.at(paid)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.find(*identifiers_and_options)
|
38
|
+
find_one_or_more('transactions', identifiers_and_options)
|
39
|
+
end
|
40
|
+
|
13
41
|
#Find all Transactions by the buyer_id
|
14
42
|
#
|
15
43
|
def self.find_all_by_buyer_id(user_id, options = {})
|
16
44
|
get_all("/users/#{user_id}/transactions", options)
|
17
45
|
end
|
18
46
|
|
47
|
+
def self.find_all_by_listing_id(listing_id, options = {})
|
48
|
+
get_all("/listings/#{listing_id}/transactions", options)
|
49
|
+
end
|
50
|
+
|
19
51
|
def self.find_all_by_receipt_id(receipt_id, options = {})
|
20
52
|
get_all("/receipts/#{receipt_id}/transactions", options)
|
21
53
|
end
|
22
54
|
|
55
|
+
def receipt
|
56
|
+
@receipt ||= Receipt.find(receipt_id, oauth)
|
57
|
+
end
|
23
58
|
|
24
59
|
def buyer
|
25
|
-
@buyer ||= User.find(buyer_id)
|
60
|
+
@buyer ||= User.find(buyer_id, oauth)
|
61
|
+
end
|
62
|
+
|
63
|
+
def listing
|
64
|
+
@listing ||= Listing.find(listing_id, oauth)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def oauth
|
70
|
+
oauth = (token && secret) ? {:access_token => token, :access_secret => secret} : {}
|
26
71
|
end
|
27
72
|
|
28
73
|
end
|
data/lib/etsy/user.rb
CHANGED
@@ -19,6 +19,8 @@ module Etsy
|
|
19
19
|
|
20
20
|
association :profile, :from => 'Profile'
|
21
21
|
association :shops, :from => 'Shops'
|
22
|
+
association :bill_charges, :from => 'BillCharges'
|
23
|
+
association :bill_payments, :from => 'BillPayments'
|
22
24
|
|
23
25
|
# Retrieve one or more users by name or ID:
|
24
26
|
#
|
@@ -81,6 +83,34 @@ module Etsy
|
|
81
83
|
@shops
|
82
84
|
end
|
83
85
|
|
86
|
+
def bill_charges
|
87
|
+
unless @bill_charges
|
88
|
+
if associated_bill_charges
|
89
|
+
@bill_charges = associated_bill_charges.map { |bill_charge| BillCharge.new(bill_charge) }
|
90
|
+
else
|
91
|
+
options = {:fields => 'user_id', :includes => 'BillCharges'}
|
92
|
+
options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)
|
93
|
+
tmp = User.find(username, options)
|
94
|
+
@bill_charges = tmp.associated_bill_charges.map { |bill_charge| BillCharge.new(bill_charge) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
@bill_charges
|
98
|
+
end
|
99
|
+
|
100
|
+
def bill_payments
|
101
|
+
unless @bill_payments
|
102
|
+
if associated_bill_payments
|
103
|
+
@bill_payments = associated_bill_payments.map { |bill_payment| BillPayment.new(bill_payment) }
|
104
|
+
else
|
105
|
+
options = {:fields => 'user_id', :includes => 'BillPayments'}
|
106
|
+
options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)
|
107
|
+
tmp = User.find(username, options)
|
108
|
+
@bill_payments = tmp.associated_bill_payments.map { |bill_payment| BillPayment.new(bill_payment) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
@bill_payments
|
112
|
+
end
|
113
|
+
|
84
114
|
# Time that this user was created
|
85
115
|
#
|
86
116
|
def created_at
|
data/lib/etsy/version.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
{
|
3
|
+
"count":4,
|
4
|
+
"results":
|
5
|
+
[
|
6
|
+
{
|
7
|
+
"property_id": 200,
|
8
|
+
"property_name": "Primary color",
|
9
|
+
"scale_id": null,
|
10
|
+
"scale_name": null,
|
11
|
+
"value_ids": [1213],
|
12
|
+
"values": ["Beige"]
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"property_id": 52047899002,
|
16
|
+
"property_name": "Secondary color",
|
17
|
+
"scale_id": null,
|
18
|
+
"scale_name": null,
|
19
|
+
"value_ids": [1],
|
20
|
+
"values": ["Black"]
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"property_id": 47626759834,
|
24
|
+
"property_name": "Height",
|
25
|
+
"scale_id": 5,
|
26
|
+
"scale_name": "Inches",
|
27
|
+
"value_ids": [0],
|
28
|
+
"values": ["15"]
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"property_id": 47626759898,
|
32
|
+
"property_name": "Width",
|
33
|
+
"scale_id": 5,
|
34
|
+
"scale_name": "Inches",
|
35
|
+
"value_ids": [0],
|
36
|
+
"values": ["25"]
|
37
|
+
}
|
38
|
+
],
|
39
|
+
"params":
|
40
|
+
{
|
41
|
+
"listing_id":"59495892"
|
42
|
+
},
|
43
|
+
"type":"ListingPropertyValue"
|
44
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"bill_charge_id":212,"type":"listing_id","type_id":14888443,"amount":"3.00"}],"params":{"user_id":"212"},"type":"BillCharge","pagination":{}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"bill_payment_id":212,"type":"listing_id","type_id":14888443,"amount":"3.00"}],"params":{"user_id":"212"},"type":"BillPayment","pagination":{}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"total_balance":1399,"balance_due":999}],"params":{"user_id":"212"},"type":"BillingOverview","pagination":{}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"count":1,"results":[{"shipping_info_id":212,"primary_cost":"$9.99","listing_id":14888443}],"params":{"shipping_template_id":"212"},"type":"ShippingTemplate","pagination":{}}
|
data/test/test_helper.rb
CHANGED
@@ -3,7 +3,6 @@ $:.reject! { |e| e.include? 'TextMate' }
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'active_support' # workaround load issue with shoulda in rubinius
|
6
|
-
require 'minitest/autorun' # workaround load issue with shoulda in rubinius
|
7
6
|
require 'test/unit'
|
8
7
|
require 'shoulda'
|
9
8
|
require 'matchy'
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class AttributeValueTest < Test::Unit::TestCase
|
5
|
+
context 'The AttributeValue class' do
|
6
|
+
context 'without oauth' do
|
7
|
+
should 'be able to find all images for a listing' do
|
8
|
+
property_values = mock_request(
|
9
|
+
'/listings/1/attributes',
|
10
|
+
{},
|
11
|
+
'AttributeValue',
|
12
|
+
'findAllListingPropertyValues.json'
|
13
|
+
)
|
14
|
+
AttributeValue.find_all_by_listing_id(1, {}).should == property_values
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with options' do
|
19
|
+
should 'be able to find all property_values for a listing with options in request' do
|
20
|
+
property_values = mock_request(
|
21
|
+
'/listings/1/attributes',
|
22
|
+
{ foo: 'bar' },
|
23
|
+
'AttributeValue',
|
24
|
+
'findAllListingPropertyValues.json'
|
25
|
+
)
|
26
|
+
AttributeValue.find_all_by_listing_id(1, foo: 'bar').should == property_values
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'An instance of the AttributeValue class' do
|
32
|
+
context 'with response data' do
|
33
|
+
setup do
|
34
|
+
data = read_fixture('attribute_value/findAllListingPropertyValues.json')
|
35
|
+
@primary_color = AttributeValue.new(data[0])
|
36
|
+
@secondary_color = AttributeValue.new(data[1])
|
37
|
+
@height = AttributeValue.new(data[2])
|
38
|
+
@width = AttributeValue.new(data[3])
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'have a value for :scale_name for width' do
|
42
|
+
@width.scale_name.should == 'Inches'
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'have a value for :scale_id for width' do
|
46
|
+
@width.scale_id.should == 5
|
47
|
+
end
|
48
|
+
|
49
|
+
should 'have a value for :scale_name for height' do
|
50
|
+
@height.scale_name.should == 'Inches'
|
51
|
+
end
|
52
|
+
|
53
|
+
should 'have a value for :scale_id for height' do
|
54
|
+
@height.scale_id.should == 5
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'have an array of :values with color name for primary_color' do
|
58
|
+
@primary_color.values.should == ['Beige']
|
59
|
+
end
|
60
|
+
|
61
|
+
should 'have an array of :values with color name for secondary_color' do
|
62
|
+
@secondary_color.values.should == ['Black']
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class BillChargeTest < Test::Unit::TestCase
|
5
|
+
context "An instance of the BillCharge class" do
|
6
|
+
setup do
|
7
|
+
data = read_fixture('bill_charge/getBillCharge.json')
|
8
|
+
@bill_charge = BillCharge.new(data.first)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have an id" do
|
12
|
+
@bill_charge.id.should == 212
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have a type" do
|
16
|
+
@bill_charge.type.should == "listing_id"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have an type_id" do
|
20
|
+
@bill_charge.type_id.should == 14888443
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class BillPaymentTest < Test::Unit::TestCase
|
5
|
+
context "An instance of the BillPayment class" do
|
6
|
+
setup do
|
7
|
+
data = read_fixture('bill_payment/getBillPayment.json')
|
8
|
+
@bill_payment = BillPayment.new(data.first)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have an id" do
|
12
|
+
@bill_payment.id.should == 212
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have a type" do
|
16
|
+
@bill_payment.type.should == "listing_id"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have an type_id" do
|
20
|
+
@bill_payment.type_id.should == 14888443
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class BillingOverviewTest < Test::Unit::TestCase
|
5
|
+
context "An instance of the BillingOverview class" do
|
6
|
+
setup do
|
7
|
+
data = read_fixture('billing_overview/getBillingOverview.json')
|
8
|
+
@billing_overview = BillingOverview.new(data.first)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have a total_balance" do
|
12
|
+
@billing_overview.total_balance.should == 1399
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have a balance_due" do
|
16
|
+
@billing_overview.balance_due.should == 999
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -30,9 +30,9 @@ module Etsy
|
|
30
30
|
end
|
31
31
|
|
32
32
|
should 'perform multiple requests if :limit is greater than 100' do
|
33
|
-
|
34
|
-
mock_empty_request(:limit =>
|
35
|
-
|
33
|
+
body = '{"count": 150, "pagination":{}}'
|
34
|
+
mock_empty_request(:limit => 100, :offset => 0, :body => body).once
|
35
|
+
mock_empty_request(:limit => 50, :offset => 100, :body => body).once
|
36
36
|
TestModel.get_all('', :limit => 150)
|
37
37
|
end
|
38
38
|
|
@@ -52,7 +52,7 @@ module Etsy
|
|
52
52
|
end
|
53
53
|
|
54
54
|
should 'perform multiple requests if :limit is :all and count is greater than 100' do
|
55
|
-
body = '{"count": 210}'
|
55
|
+
body = '{"count": 210, "pagination": {}}'
|
56
56
|
mock_empty_request(:limit => 100, :offset => 0, :body => body).once
|
57
57
|
mock_empty_request(:limit => 100, :offset => 100, :body => body).once
|
58
58
|
mock_empty_request(:limit => 10, :offset => 200, :body => body).once
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class ShippingInfoTest < Test::Unit::TestCase
|
5
|
+
context "An instance of the ShippingInfo class" do
|
6
|
+
setup do
|
7
|
+
data = read_fixture('shipping_info/getShippingInfo.json')
|
8
|
+
@shipping_info = ShippingInfo.new(data.first)
|
9
|
+
end
|
10
|
+
|
11
|
+
should "have an id" do
|
12
|
+
@shipping_info.id.should == 212
|
13
|
+
end
|
14
|
+
|
15
|
+
should "have an title" do
|
16
|
+
@shipping_info.primary_cost.should == "$9.99"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have an listing_id" do
|
20
|
+
@shipping_info.listing_id.should == 14888443
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etsy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -109,21 +109,21 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.13.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: test-unit
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: 3.2.5
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ~>
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: 3.2.5
|
127
127
|
description: A friendly Ruby interface to the Etsy API
|
128
128
|
email:
|
129
129
|
- reaganpr@gmail.com
|
@@ -142,7 +142,11 @@ files:
|
|
142
142
|
- lib/etsy.rb
|
143
143
|
- lib/etsy/about.rb
|
144
144
|
- lib/etsy/address.rb
|
145
|
+
- lib/etsy/attribute_value.rb
|
145
146
|
- lib/etsy/basic_client.rb
|
147
|
+
- lib/etsy/bill_charge.rb
|
148
|
+
- lib/etsy/bill_payment.rb
|
149
|
+
- lib/etsy/billing_overview.rb
|
146
150
|
- lib/etsy/category.rb
|
147
151
|
- lib/etsy/country.rb
|
148
152
|
- lib/etsy/favorite_listing.rb
|
@@ -156,6 +160,7 @@ files:
|
|
156
160
|
- lib/etsy/response.rb
|
157
161
|
- lib/etsy/section.rb
|
158
162
|
- lib/etsy/secure_client.rb
|
163
|
+
- lib/etsy/shipping_info.rb
|
159
164
|
- lib/etsy/shipping_template.rb
|
160
165
|
- lib/etsy/shop.rb
|
161
166
|
- lib/etsy/transaction.rb
|
@@ -165,6 +170,10 @@ files:
|
|
165
170
|
- lib/etsy/version.rb
|
166
171
|
- test/fixtures/about/getAbout.json
|
167
172
|
- test/fixtures/address/getUserAddresses.json
|
173
|
+
- test/fixtures/attribute_value/findAllListingPropertyValues.json
|
174
|
+
- test/fixtures/bill_charge/getBillCharge.json
|
175
|
+
- test/fixtures/bill_payment/getBillPayment.json
|
176
|
+
- test/fixtures/billing_overview/getBillingOverview.json
|
168
177
|
- test/fixtures/category/findAllSubCategoryChildren.json
|
169
178
|
- test/fixtures/category/findAllTopCategory.json
|
170
179
|
- test/fixtures/category/findAllTopCategory.single.json
|
@@ -183,6 +192,7 @@ files:
|
|
183
192
|
- test/fixtures/profile/new.json
|
184
193
|
- test/fixtures/receipt/findAllShopReceipts.json
|
185
194
|
- test/fixtures/section/getShopSection.json
|
195
|
+
- test/fixtures/shipping_info/getShippingInfo.json
|
186
196
|
- test/fixtures/shipping_template/getShippingTemplate.json
|
187
197
|
- test/fixtures/shop/findAllShop.json
|
188
198
|
- test/fixtures/shop/findAllShop.single.json
|
@@ -196,7 +206,11 @@ files:
|
|
196
206
|
- test/fixtures/user/getUser.single.withShops.json
|
197
207
|
- test/test_helper.rb
|
198
208
|
- test/unit/etsy/address_test.rb
|
209
|
+
- test/unit/etsy/attribute_value_test.rb
|
199
210
|
- test/unit/etsy/basic_client_test.rb
|
211
|
+
- test/unit/etsy/bill_charge_test.rb
|
212
|
+
- test/unit/etsy/bill_payment_test.rb
|
213
|
+
- test/unit/etsy/billing_overview_test.rb
|
200
214
|
- test/unit/etsy/category_test.rb
|
201
215
|
- test/unit/etsy/country_test.rb
|
202
216
|
- test/unit/etsy/favorite_listing_test.rb
|
@@ -210,6 +224,7 @@ files:
|
|
210
224
|
- test/unit/etsy/response_test.rb
|
211
225
|
- test/unit/etsy/section_test.rb
|
212
226
|
- test/unit/etsy/secure_client_test.rb
|
227
|
+
- test/unit/etsy/shipping_info_test.rb
|
213
228
|
- test/unit/etsy/shipping_template_test.rb
|
214
229
|
- test/unit/etsy/shop_about_test.rb
|
215
230
|
- test/unit/etsy/shop_test.rb
|
@@ -245,6 +260,10 @@ summary: Provides a friendly ruby-like wrapper for the Etsy API
|
|
245
260
|
test_files:
|
246
261
|
- test/fixtures/about/getAbout.json
|
247
262
|
- test/fixtures/address/getUserAddresses.json
|
263
|
+
- test/fixtures/attribute_value/findAllListingPropertyValues.json
|
264
|
+
- test/fixtures/bill_charge/getBillCharge.json
|
265
|
+
- test/fixtures/bill_payment/getBillPayment.json
|
266
|
+
- test/fixtures/billing_overview/getBillingOverview.json
|
248
267
|
- test/fixtures/category/findAllSubCategoryChildren.json
|
249
268
|
- test/fixtures/category/findAllTopCategory.json
|
250
269
|
- test/fixtures/category/findAllTopCategory.single.json
|
@@ -263,6 +282,7 @@ test_files:
|
|
263
282
|
- test/fixtures/profile/new.json
|
264
283
|
- test/fixtures/receipt/findAllShopReceipts.json
|
265
284
|
- test/fixtures/section/getShopSection.json
|
285
|
+
- test/fixtures/shipping_info/getShippingInfo.json
|
266
286
|
- test/fixtures/shipping_template/getShippingTemplate.json
|
267
287
|
- test/fixtures/shop/findAllShop.json
|
268
288
|
- test/fixtures/shop/findAllShop.single.json
|
@@ -276,7 +296,11 @@ test_files:
|
|
276
296
|
- test/fixtures/user/getUser.single.withShops.json
|
277
297
|
- test/test_helper.rb
|
278
298
|
- test/unit/etsy/address_test.rb
|
299
|
+
- test/unit/etsy/attribute_value_test.rb
|
279
300
|
- test/unit/etsy/basic_client_test.rb
|
301
|
+
- test/unit/etsy/bill_charge_test.rb
|
302
|
+
- test/unit/etsy/bill_payment_test.rb
|
303
|
+
- test/unit/etsy/billing_overview_test.rb
|
280
304
|
- test/unit/etsy/category_test.rb
|
281
305
|
- test/unit/etsy/country_test.rb
|
282
306
|
- test/unit/etsy/favorite_listing_test.rb
|
@@ -290,6 +314,7 @@ test_files:
|
|
290
314
|
- test/unit/etsy/response_test.rb
|
291
315
|
- test/unit/etsy/section_test.rb
|
292
316
|
- test/unit/etsy/secure_client_test.rb
|
317
|
+
- test/unit/etsy/shipping_info_test.rb
|
293
318
|
- test/unit/etsy/shipping_template_test.rb
|
294
319
|
- test/unit/etsy/shop_about_test.rb
|
295
320
|
- test/unit/etsy/shop_test.rb
|