etsy 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/etsy.rb +1 -0
- data/lib/etsy/receipt.rb +24 -0
- data/lib/etsy/version.rb +1 -1
- data/test/fixtures/receipt/findAllShopReceipts.json +28 -0
- data/test/unit/etsy/receipt_test.rb +92 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63b1728090ce087c6421fdb354545b5031206bdd
|
4
|
+
data.tar.gz: 720fd11d6f39fe99e5f414e54155db73c2bedce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c7a7b67c5bb186cecfe0a61000dd6b2a6258d5e4bd915c67672e40d949af76d7c083bfd54ec7e96c7d0396665562c389deafd3a1422ca21e6a4553a47a1f5aa
|
7
|
+
data.tar.gz: 60c5ad5ef28a7f5104ffcbb9e6df25f292ab31292725e9a45dddfe8fe62a93ac22ce1d0ea22d18c98db91e37b7d66e4bbc676ad6d7f422a339b86b878edc7eb7
|
data/lib/etsy.rb
CHANGED
data/lib/etsy/receipt.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Etsy
|
2
|
+
class Receipt
|
3
|
+
include Model
|
4
|
+
|
5
|
+
attribute :id, :from => :receipt_id
|
6
|
+
attribute :buyer_id, :from => :buyer_user_id
|
7
|
+
|
8
|
+
attributes :quantity, :listing_id, :name, :first_line, :second_line, :city, :state, :zip, :country_id,
|
9
|
+
:payment_email, :buyer_email, :created_tsz
|
10
|
+
|
11
|
+
def self.find_all_by_shop_id(shop_id, options = {})
|
12
|
+
get_all("/shops/#{shop_id}/receipts", options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def created_at
|
16
|
+
Time.at(created_tsz)
|
17
|
+
end
|
18
|
+
|
19
|
+
def buyer
|
20
|
+
@buyer ||= User.find(buyer_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/etsy/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"count":1,
|
3
|
+
"results":
|
4
|
+
[
|
5
|
+
{
|
6
|
+
"receipt_id":27230877,
|
7
|
+
"buyer_user_id":12345,
|
8
|
+
"created_tsz":1412206858,
|
9
|
+
"quantity":5,
|
10
|
+
"listing_id":123456,
|
11
|
+
"name":"Mike Taylor",
|
12
|
+
"first_line":"123 Fun St",
|
13
|
+
"second_line":"#3b",
|
14
|
+
"city":"San Francisco",
|
15
|
+
"state":"CA",
|
16
|
+
"zip":"94501",
|
17
|
+
"country_id":201,
|
18
|
+
"payment_email":"foo@example.com",
|
19
|
+
"buyer_email":"bar@example.com"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"params": {
|
23
|
+
"shop_id":"5818087",
|
24
|
+
"limit":25,
|
25
|
+
"offset":0
|
26
|
+
},
|
27
|
+
"type":"Receipt"
|
28
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Etsy
|
4
|
+
class ReceiptTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "The Receipt class" do
|
7
|
+
|
8
|
+
should "be able to find receipts for a shop" do
|
9
|
+
receipts = mock_request('/shops/1/receipts', {'key' => 'value'}, 'Receipt', 'findAllShopReceipts.json')
|
10
|
+
Receipt.find_all_by_shop_id(1, {'key' => 'value'}).should == receipts
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
context "An instance of the Receipt class" do
|
16
|
+
|
17
|
+
context "with response data" do
|
18
|
+
setup do
|
19
|
+
data = read_fixture('receipt/findAllShopReceipts.json')
|
20
|
+
@receipt = Receipt.new(data.first)
|
21
|
+
end
|
22
|
+
|
23
|
+
should "have a value for :id" do
|
24
|
+
@receipt.id.should == 27230877
|
25
|
+
end
|
26
|
+
|
27
|
+
should "have :buyer_id" do
|
28
|
+
@receipt.buyer_id.should == 12345
|
29
|
+
end
|
30
|
+
|
31
|
+
should "have :created_at" do
|
32
|
+
@receipt.created_at.should == Time.at(1412206858)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "have a value for :quantity" do
|
36
|
+
@receipt.quantity.should == 5
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have a value for :listing_id" do
|
40
|
+
@receipt.listing_id.should == 123456
|
41
|
+
end
|
42
|
+
|
43
|
+
should "have a value for name" do
|
44
|
+
@receipt.name.should == "Mike Taylor"
|
45
|
+
end
|
46
|
+
|
47
|
+
should "have a value for first_line" do
|
48
|
+
@receipt.first_line.should == "123 Fun St"
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a value for second_line" do
|
52
|
+
@receipt.second_line.should == "#3b"
|
53
|
+
end
|
54
|
+
|
55
|
+
should "have a value for city" do
|
56
|
+
@receipt.city.should == "San Francisco"
|
57
|
+
end
|
58
|
+
|
59
|
+
should "have a value for state" do
|
60
|
+
@receipt.state.should == "CA"
|
61
|
+
end
|
62
|
+
|
63
|
+
should "have a value for zip" do
|
64
|
+
@receipt.zip.should == "94501"
|
65
|
+
end
|
66
|
+
|
67
|
+
should "have a value for country_id" do
|
68
|
+
@receipt.country_id.should == 201
|
69
|
+
end
|
70
|
+
|
71
|
+
should "have a value for payment_email" do
|
72
|
+
@receipt.payment_email.should == "foo@example.com"
|
73
|
+
end
|
74
|
+
|
75
|
+
should "have a value for buyer_email" do
|
76
|
+
@receipt.buyer_email.should == "bar@example.com"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
should "know the buyer" do
|
81
|
+
User.stubs(:find).with(1).returns('user')
|
82
|
+
|
83
|
+
receipt = Receipt.new
|
84
|
+
receipt.stubs(:buyer_id).with().returns(1)
|
85
|
+
|
86
|
+
receipt.buyer.should == 'user'
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Reagan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/etsy/model.rb
|
136
136
|
- lib/etsy/payment_template.rb
|
137
137
|
- lib/etsy/profile.rb
|
138
|
+
- lib/etsy/receipt.rb
|
138
139
|
- lib/etsy/request.rb
|
139
140
|
- lib/etsy/response.rb
|
140
141
|
- lib/etsy/section.rb
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- test/fixtures/listing/getListing.single.json
|
162
163
|
- test/fixtures/payment_template/getPaymentTemplate.json
|
163
164
|
- test/fixtures/profile/new.json
|
165
|
+
- test/fixtures/receipt/findAllShopReceipts.json
|
164
166
|
- test/fixtures/section/getShopSection.json
|
165
167
|
- test/fixtures/shipping_template/getShippingTemplate.json
|
166
168
|
- test/fixtures/shop/findAllShop.json
|
@@ -184,6 +186,7 @@ files:
|
|
184
186
|
- test/unit/etsy/model_test.rb
|
185
187
|
- test/unit/etsy/payment_template_test.rb
|
186
188
|
- test/unit/etsy/profile_test.rb
|
189
|
+
- test/unit/etsy/receipt_test.rb
|
187
190
|
- test/unit/etsy/request_test.rb
|
188
191
|
- test/unit/etsy/response_test.rb
|
189
192
|
- test/unit/etsy/section_test.rb
|
@@ -235,6 +238,7 @@ test_files:
|
|
235
238
|
- test/fixtures/listing/getListing.single.json
|
236
239
|
- test/fixtures/payment_template/getPaymentTemplate.json
|
237
240
|
- test/fixtures/profile/new.json
|
241
|
+
- test/fixtures/receipt/findAllShopReceipts.json
|
238
242
|
- test/fixtures/section/getShopSection.json
|
239
243
|
- test/fixtures/shipping_template/getShippingTemplate.json
|
240
244
|
- test/fixtures/shop/findAllShop.json
|
@@ -258,6 +262,7 @@ test_files:
|
|
258
262
|
- test/unit/etsy/model_test.rb
|
259
263
|
- test/unit/etsy/payment_template_test.rb
|
260
264
|
- test/unit/etsy/profile_test.rb
|
265
|
+
- test/unit/etsy/receipt_test.rb
|
261
266
|
- test/unit/etsy/request_test.rb
|
262
267
|
- test/unit/etsy/response_test.rb
|
263
268
|
- test/unit/etsy/section_test.rb
|