square 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/square/connect.rb +2 -0
- data/lib/square/connect/discount.rb +15 -0
- data/lib/square/connect/item_detail.rb +12 -0
- data/lib/square/connect/itemization.rb +23 -1
- data/lib/square/connect/payment.rb +2 -2
- data/lib/square/connect/refund.rb +1 -1
- data/lib/square/connect/settlement_entry.rb +1 -1
- data/lib/square/connect/tax.rb +1 -1
- data/lib/square/connect/tender.rb +1 -1
- data/spec/mock_response/payments/single.json +76 -31
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c69815a2bbecd018c786658bc33b8f25f213d30a
|
4
|
+
data.tar.gz: 806628a81f4ee2557fbe5f190715b913bcb94d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d23dbe3e865707b467c8ec1c68dc7ca3cba76ec2a9acd0994e89b380db1b291bee73656d97387e111ddab82e4ab10cdeb59bbfad1970de99d2b7285b6b61822f
|
7
|
+
data.tar.gz: ed11380a1921f8d9e168099ccb68203432adde6cc2bfdd7ba38012eb49e80ceeac38e565eb2cd2152bd882d5ce61c6e429fd6006beedb545eec61d92653c5eb2
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/square/connect.rb
CHANGED
@@ -14,7 +14,9 @@ require 'square/connect/payment'
|
|
14
14
|
require 'square/connect/settlement'
|
15
15
|
|
16
16
|
require 'square/connect/device'
|
17
|
+
require 'square/connect/discount'
|
17
18
|
require 'square/connect/itemization'
|
19
|
+
require 'square/connect/item_detail'
|
18
20
|
require 'square/connect/money'
|
19
21
|
require 'square/connect/refund'
|
20
22
|
require 'square/connect/tax'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Square
|
2
|
+
module Connect
|
3
|
+
class Discount
|
4
|
+
attr_accessor :name, :applied_money
|
5
|
+
|
6
|
+
def initialize(attributes = {})
|
7
|
+
raise
|
8
|
+
self.name = attributes[:name]
|
9
|
+
self.applied_money = if attributes[:applied_money]
|
10
|
+
Money.new attributes[:applied_money]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -4,7 +4,29 @@ module Square
|
|
4
4
|
attr_accessor :name, :quantity, :item_detail, :notes, :item_variation_name, :total_money, :single_quantity_money, :gross_sales_money, :discount_money, :taxes, :discounts
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
|
-
|
7
|
+
self.name = attributes[:name]
|
8
|
+
self.quantity = attributes[:quantity]
|
9
|
+
self.item_detail = if attributes[:item_detail].present?
|
10
|
+
ItemDetail.new attributes[:item_detail]
|
11
|
+
end
|
12
|
+
self.notes = attributes[:notes]
|
13
|
+
self.item_variation_name = attributes[:item_variation_name]
|
14
|
+
[
|
15
|
+
:total_money,
|
16
|
+
:single_quantity_money,
|
17
|
+
:gross_sales_money,
|
18
|
+
:discount_money
|
19
|
+
].each do |money_key|
|
20
|
+
if attributes[money_key]
|
21
|
+
self.send "#{money_key}=", Money.new(attributes[money_key])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
self.taxes = Array(attributes[:taxes]).collect do |tax_attributes|
|
25
|
+
Tax.new tax_attributes
|
26
|
+
end
|
27
|
+
self.discounts = Array(attributes[:discounts]).collect do |discount_attributes|
|
28
|
+
Discount.new discount_attributes
|
29
|
+
end
|
8
30
|
end
|
9
31
|
end
|
10
32
|
end
|
@@ -37,7 +37,7 @@ module Square
|
|
37
37
|
Time.parse attributes[:created_at]
|
38
38
|
end
|
39
39
|
self.description = attributes[:description]
|
40
|
-
self.device = if attributes[:device]
|
40
|
+
self.device = if attributes[:device]
|
41
41
|
Device.new attributes[:device]
|
42
42
|
end
|
43
43
|
[
|
@@ -51,7 +51,7 @@ module Square
|
|
51
51
|
:net_total_money,
|
52
52
|
:refunded_money
|
53
53
|
].each do |money_key|
|
54
|
-
if attributes[money_key]
|
54
|
+
if attributes[money_key]
|
55
55
|
self.send "#{money_key}=", Money.new(attributes[money_key])
|
56
56
|
end
|
57
57
|
end
|
@@ -7,7 +7,7 @@ module Square
|
|
7
7
|
self.identifier = attributes[:id]
|
8
8
|
self.type = attributes[:type]
|
9
9
|
self.reason = attributes[:reason]
|
10
|
-
self.refunded_money = if attributes[:refunded_money]
|
10
|
+
self.refunded_money = if attributes[:refunded_money]
|
11
11
|
Money.new attributes[:refunded_money]
|
12
12
|
end
|
13
13
|
[
|
data/lib/square/connect/tax.rb
CHANGED
@@ -5,7 +5,7 @@ module Square
|
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
7
|
self.name = attributes[:name]
|
8
|
-
self.applied_money = if attributes[:applied_money]
|
8
|
+
self.applied_money = if attributes[:applied_money]
|
9
9
|
Money.new attributes[:applied_money]
|
10
10
|
end
|
11
11
|
self.rate = attributes[:rate]
|
@@ -1,61 +1,106 @@
|
|
1
1
|
{
|
2
|
-
"id": "
|
3
|
-
"merchant_id": "
|
4
|
-
"
|
5
|
-
"
|
2
|
+
"id": "Jq74mCczmFXk1tC10GB",
|
3
|
+
"merchant_id": "AV76FTXT15L",
|
4
|
+
"created_at": "2013-01-02T00:00:00.000Z",
|
5
|
+
"creator_id": "B5CX9A21Z",
|
6
|
+
"description": "Lunch for one",
|
6
7
|
"device": {
|
7
|
-
"name": "
|
8
|
+
"name": "Front of store"
|
8
9
|
},
|
9
10
|
"inclusive_tax_money": {
|
10
|
-
"amount":
|
11
|
-
"currency_code": "
|
11
|
+
"amount": 20,
|
12
|
+
"currency_code": "USD"
|
12
13
|
},
|
13
14
|
"additive_tax_money": {
|
14
|
-
"amount":
|
15
|
-
"currency_code": "
|
15
|
+
"amount": 30,
|
16
|
+
"currency_code": "USD"
|
16
17
|
},
|
17
18
|
"tax_money": {
|
18
|
-
"amount":
|
19
|
-
"currency_code": "
|
19
|
+
"amount": 50,
|
20
|
+
"currency_code": "USD"
|
20
21
|
},
|
21
22
|
"tip_money": {
|
22
|
-
"amount":
|
23
|
-
"currency_code": "
|
23
|
+
"amount": 100,
|
24
|
+
"currency_code": "USD"
|
24
25
|
},
|
25
26
|
"discount_money": {
|
26
27
|
"amount": 0,
|
27
|
-
"currency_code": "
|
28
|
+
"currency_code": "USD"
|
28
29
|
},
|
29
30
|
"total_collected_money": {
|
30
|
-
"amount":
|
31
|
-
"currency_code": "
|
31
|
+
"amount": 6150,
|
32
|
+
"currency_code": "USD"
|
32
33
|
},
|
33
34
|
"processing_fee_money": {
|
34
|
-
"amount":
|
35
|
-
"currency_code": "
|
35
|
+
"amount": -169,
|
36
|
+
"currency_code": "USD"
|
36
37
|
},
|
37
38
|
"net_total_money": {
|
38
|
-
"amount":
|
39
|
-
"currency_code": "
|
39
|
+
"amount": 5981,
|
40
|
+
"currency_code": "USD"
|
40
41
|
},
|
41
42
|
"refunded_money": {
|
42
43
|
"amount": 0,
|
43
|
-
"currency_code": "
|
44
|
+
"currency_code": "USD"
|
44
45
|
},
|
45
|
-
"inclusive_tax": [
|
46
|
-
|
46
|
+
"inclusive_tax": [{
|
47
|
+
"inclusion_type": "INCLUSIVE",
|
48
|
+
"name": "City tax",
|
49
|
+
"applied_money": {
|
50
|
+
"amount": 15,
|
51
|
+
"currency_code": "USD"
|
52
|
+
},
|
53
|
+
"rate": "0.0025"
|
54
|
+
}],
|
55
|
+
"additive_tax": [{
|
56
|
+
"inclusion_type": "ADDITIVE",
|
57
|
+
"name": "CA Sales tax",
|
58
|
+
"applied_money": {
|
59
|
+
"amount": 15,
|
60
|
+
"currency_code": "USD"
|
61
|
+
},
|
62
|
+
"rate": "0.0025"
|
63
|
+
}],
|
47
64
|
"tender": [{
|
48
|
-
"type": "
|
49
|
-
"name": "Cash",
|
65
|
+
"type": "CREDIT_CARD",
|
50
66
|
"total_money": {
|
51
|
-
"amount":
|
52
|
-
"currency_code": "
|
67
|
+
"amount": 6150,
|
68
|
+
"currency_code": "USD"
|
53
69
|
},
|
54
|
-
"
|
55
|
-
|
56
|
-
|
70
|
+
"card_brand": "VISA",
|
71
|
+
"pan_suffix": "1234",
|
72
|
+
"entry_method": "SWIPED",
|
73
|
+
"payment_note": "A note about the tender",
|
74
|
+
"total_money": {
|
75
|
+
"amount": 500,
|
76
|
+
"currency_code": "USD"
|
57
77
|
}
|
58
78
|
}],
|
59
79
|
"refunds": [],
|
60
|
-
"itemizations": [
|
80
|
+
"itemizations": [{
|
81
|
+
"name": "Donut",
|
82
|
+
"quantity": 12,
|
83
|
+
"item_detail": {
|
84
|
+
"category_name": "Pastries",
|
85
|
+
"sku": 1234
|
86
|
+
},
|
87
|
+
"total_money": {
|
88
|
+
"amount": 6000,
|
89
|
+
"currency_code": "USD"
|
90
|
+
},
|
91
|
+
"single_quantity_money": {
|
92
|
+
"amount": 500,
|
93
|
+
"currency_code": "USD"
|
94
|
+
},
|
95
|
+
"gross_sales_money": {
|
96
|
+
"amount": 6000,
|
97
|
+
"currency_code": "USD"
|
98
|
+
},
|
99
|
+
"discount_money": {
|
100
|
+
"amount": 0,
|
101
|
+
"currency_code": "USD"
|
102
|
+
},
|
103
|
+
"taxes": [],
|
104
|
+
"discounts": []
|
105
|
+
}]
|
61
106
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-oauth2
|
@@ -117,7 +117,9 @@ files:
|
|
117
117
|
- lib/square/connect/connections/refunds.rb
|
118
118
|
- lib/square/connect/connections/settlements.rb
|
119
119
|
- lib/square/connect/device.rb
|
120
|
+
- lib/square/connect/discount.rb
|
120
121
|
- lib/square/connect/error.rb
|
122
|
+
- lib/square/connect/item_detail.rb
|
121
123
|
- lib/square/connect/itemization.rb
|
122
124
|
- lib/square/connect/merchant.rb
|
123
125
|
- lib/square/connect/money.rb
|