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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97640cf10444f7f9e41bb8fc733f6e4a058a5334
4
- data.tar.gz: f564a55d6901749b0955f43e0d7fa69aa1f1e4c4
3
+ metadata.gz: c69815a2bbecd018c786658bc33b8f25f213d30a
4
+ data.tar.gz: 806628a81f4ee2557fbe5f190715b913bcb94d16
5
5
  SHA512:
6
- metadata.gz: 6ca3a04861c402d4770a156b4a0c371d449e75519a352ab67f95e70bccebdca813f825c4396f32ebbb23ae6f7f85201956d8f9949e6d204a60421c76f7a23655
7
- data.tar.gz: 8c6f1eb1b9f612bb30f4c3655ca7c371ebc2e45d6336a67863102fb7fdbdb1f7081df2f055e70238d1a7d92bdade5a5fe7626fae49a5702564b8a88acdecf6be
6
+ metadata.gz: d23dbe3e865707b467c8ec1c68dc7ca3cba76ec2a9acd0994e89b380db1b291bee73656d97387e111ddab82e4ab10cdeb59bbfad1970de99d2b7285b6b61822f
7
+ data.tar.gz: ed11380a1921f8d9e168099ccb68203432adde6cc2bfdd7ba38012eb49e80ceeac38e565eb2cd2152bd882d5ce61c6e429fd6006beedb545eec61d92653c5eb2
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ### OAuth 2.0
24
24
 
25
- client = Square::Client.new(
25
+ client = Square::OAuth2::Client.new(
26
26
  '<your-client-id>',
27
27
  redirect_uri: 'https://example.client.com/callback'
28
28
  )
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -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
@@ -0,0 +1,12 @@
1
+ module Square
2
+ module Connect
3
+ class ItemDetail
4
+ attr_accessor :category_name, :sku
5
+
6
+ def initialize(attributes = {})
7
+ self.category_name = attributes[:category_name]
8
+ self.sku = attributes[:sku]
9
+ end
10
+ end
11
+ end
12
+ 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
- # TODO
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].present?
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].present?
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].present?
10
+ self.refunded_money = if attributes[:refunded_money]
11
11
  Money.new attributes[:refunded_money]
12
12
  end
13
13
  [
@@ -12,7 +12,7 @@ module Square
12
12
  :amount_money,
13
13
  :fee_money
14
14
  ].each do |money_key|
15
- if attributes[money_key].present?
15
+ if attributes[money_key]
16
16
  self.send "#{money_key}=", Money.new(attributes[money_key])
17
17
  end
18
18
  end
@@ -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].present?
8
+ self.applied_money = if attributes[:applied_money]
9
9
  Money.new attributes[:applied_money]
10
10
  end
11
11
  self.rate = attributes[:rate]
@@ -15,7 +15,7 @@ module Square
15
15
  :tendered_money,
16
16
  :change_back_money
17
17
  ].each do |money_attr|
18
- if attributes[money_attr].present?
18
+ if attributes[money_attr]
19
19
  self.send "#{money_attr}=", Money.new(attributes[money_attr])
20
20
  end
21
21
  end
@@ -1,61 +1,106 @@
1
1
  {
2
- "id": "payment_1",
3
- "merchant_id": "merchant_id",
4
- "creator_id": "creator_id",
5
- "created_at": "2013-05-23T09:43:59Z",
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": "iPhone"
8
+ "name": "Front of store"
8
9
  },
9
10
  "inclusive_tax_money": {
10
- "amount": 0,
11
- "currency_code": "JPY"
11
+ "amount": 20,
12
+ "currency_code": "USD"
12
13
  },
13
14
  "additive_tax_money": {
14
- "amount": 0,
15
- "currency_code": "JPY"
15
+ "amount": 30,
16
+ "currency_code": "USD"
16
17
  },
17
18
  "tax_money": {
18
- "amount": 0,
19
- "currency_code": "JPY"
19
+ "amount": 50,
20
+ "currency_code": "USD"
20
21
  },
21
22
  "tip_money": {
22
- "amount": 0,
23
- "currency_code": "JPY"
23
+ "amount": 100,
24
+ "currency_code": "USD"
24
25
  },
25
26
  "discount_money": {
26
27
  "amount": 0,
27
- "currency_code": "JPY"
28
+ "currency_code": "USD"
28
29
  },
29
30
  "total_collected_money": {
30
- "amount": 0,
31
- "currency_code": "JPY"
31
+ "amount": 6150,
32
+ "currency_code": "USD"
32
33
  },
33
34
  "processing_fee_money": {
34
- "amount": 0,
35
- "currency_code": "JPY"
35
+ "amount": -169,
36
+ "currency_code": "USD"
36
37
  },
37
38
  "net_total_money": {
38
- "amount": 0,
39
- "currency_code": "JPY"
39
+ "amount": 5981,
40
+ "currency_code": "USD"
40
41
  },
41
42
  "refunded_money": {
42
43
  "amount": 0,
43
- "currency_code": "JPY"
44
+ "currency_code": "USD"
44
45
  },
45
- "inclusive_tax": [],
46
- "additive_tax": [],
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": "CASH",
49
- "name": "Cash",
65
+ "type": "CREDIT_CARD",
50
66
  "total_money": {
51
- "amount": 0,
52
- "currency_code": "JPY"
67
+ "amount": 6150,
68
+ "currency_code": "USD"
53
69
  },
54
- "tendered_money": {
55
- "amount": 0,
56
- "currency_code": "JPY"
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.3
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-12 00:00:00.000000000 Z
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