square-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/square.rb +206 -0
- data/lib/square/api_operations/create.rb +30 -0
- data/lib/square/api_operations/delete.rb +24 -0
- data/lib/square/api_operations/list.rb +21 -0
- data/lib/square/api_operations/retrieve.rb +21 -0
- data/lib/square/api_operations/update.rb +25 -0
- data/lib/square/api_resource.rb +55 -0
- data/lib/square/bank_accounts.rb +10 -0
- data/lib/square/category.rb +12 -0
- data/lib/square/data_type.rb +7 -0
- data/lib/square/data_types/bank_account.rb +32 -0
- data/lib/square/data_types/category.rb +12 -0
- data/lib/square/data_types/coordinates.rb +12 -0
- data/lib/square/data_types/device.rb +12 -0
- data/lib/square/data_types/discount.rb +36 -0
- data/lib/square/data_types/fee.rb +39 -0
- data/lib/square/data_types/global_address.rb +67 -0
- data/lib/square/data_types/inventory_entry.rb +12 -0
- data/lib/square/data_types/item.rb +79 -0
- data/lib/square/data_types/item_image.rb +12 -0
- data/lib/square/data_types/item_variation.rb +49 -0
- data/lib/square/data_types/merchant.rb +61 -0
- data/lib/square/data_types/merchant_location_details.rb +11 -0
- data/lib/square/data_types/modifier_list.rb +19 -0
- data/lib/square/data_types/modifier_option.rb +30 -0
- data/lib/square/data_types/money.rb +40 -0
- data/lib/square/data_types/payment.rb +87 -0
- data/lib/square/data_types/payment_discount.rb +17 -0
- data/lib/square/data_types/payment_item_detail.rb +18 -0
- data/lib/square/data_types/payment_itemization.rb +53 -0
- data/lib/square/data_types/payment_modifier.rb +16 -0
- data/lib/square/data_types/payment_tax.rb +23 -0
- data/lib/square/data_types/phone_number.rb +13 -0
- data/lib/square/data_types/refund.rb +31 -0
- data/lib/square/data_types/settlement.rb +28 -0
- data/lib/square/data_types/settlement_entry.rb +21 -0
- data/lib/square/data_types/tender.rb +50 -0
- data/lib/square/discount.rb +12 -0
- data/lib/square/fee.rb +49 -0
- data/lib/square/inventory.rb +26 -0
- data/lib/square/item.rb +40 -0
- data/lib/square/list_response.rb +79 -0
- data/lib/square/merchant.rb +13 -0
- data/lib/square/payment.rb +10 -0
- data/lib/square/refund.rb +10 -0
- data/lib/square/settlement.rb +10 -0
- data/lib/square/variation.rb +12 -0
- data/lib/square/version.rb +3 -0
- data/lib/square/webhook.rb +10 -0
- data/square-ruby.gemspec +31 -0
- metadata +219 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-itemimage
|
4
|
+
class ItemImage < Square::DataType
|
5
|
+
# The image's unique ID.
|
6
|
+
property :id
|
7
|
+
|
8
|
+
# The image's publicly accessible URL.
|
9
|
+
property :url
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-itemvariation
|
4
|
+
class ItemVariation < DataType
|
5
|
+
# The item variation's unique ID.
|
6
|
+
property :id
|
7
|
+
|
8
|
+
# The item variation's name.
|
9
|
+
property :name
|
10
|
+
|
11
|
+
# The ID of the variation's associated item.
|
12
|
+
property :item_id
|
13
|
+
|
14
|
+
# Indicates the variation's list position when displayed in Square
|
15
|
+
# Register and the merchant dashboard. If more than one variation for
|
16
|
+
# the same item has the same ordinal value, those variations are
|
17
|
+
# displayed in alphabetical order.
|
18
|
+
# An item's variation with the lowest ordinal value is displayed first.
|
19
|
+
property :ordinal # number
|
20
|
+
|
21
|
+
# Indicates whether the item variation's price is fixed or determined at
|
22
|
+
# the time of sale.
|
23
|
+
property :pricing_type # ItemVariation.PricingType
|
24
|
+
|
25
|
+
# The item variation's price, if any.
|
26
|
+
property :price_money, coerce: Square::DataTypes::Money
|
27
|
+
|
28
|
+
# The item variation's SKU, if any.
|
29
|
+
property :sku
|
30
|
+
|
31
|
+
# If true, inventory tracking is active for the variation.
|
32
|
+
property :track_inventory # boolean
|
33
|
+
|
34
|
+
# Indicates whether the item variation displays an alert when its
|
35
|
+
# inventory quantity is less than or equal to its
|
36
|
+
# inventory_alert_threshold.
|
37
|
+
property :inventory_alert_type # InventoryAlertType
|
38
|
+
|
39
|
+
# If the inventory quantity for the variation is less than or equal to
|
40
|
+
# this value and inventory_alert_type is LOW_QUANTITY, the variation
|
41
|
+
# displays an alert in the merchant dashboard.
|
42
|
+
# This value is always an integer.
|
43
|
+
property :inventory_alert_threshold # number
|
44
|
+
|
45
|
+
# Arbitrary metadata associated with the variation. Cannot exceed 255 characters.
|
46
|
+
property :user_data
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-merchant
|
4
|
+
class Merchant < Square::DataType
|
5
|
+
# The merchant account's unique identifier.
|
6
|
+
property :id
|
7
|
+
|
8
|
+
# The name associated with the merchant account.
|
9
|
+
property :name
|
10
|
+
|
11
|
+
# The email address associated with the merchant account.
|
12
|
+
property :email
|
13
|
+
|
14
|
+
# Indicates whether the merchant account corresponds to a single-location
|
15
|
+
# account (LOCATION) or a business account (BUSINESS). This value is
|
16
|
+
# almost always LOCATION. See Multi-Location Overview for more
|
17
|
+
# information.
|
18
|
+
property :account_type # Merchant.AccountType
|
19
|
+
|
20
|
+
# Capabilities that are enabled for the merchant's Square account.
|
21
|
+
# Capabilities that are not listed in this array are not enabled for
|
22
|
+
# the account. Currently there is only one capability,
|
23
|
+
# CREDIT_CARD_PROCESSING.
|
24
|
+
property :account_capabilities, coerce: Array[String] # Merchant.AccountCapability[]
|
25
|
+
|
26
|
+
# The country associated with the merchant account, in
|
27
|
+
# ISO 3166-1-alpha-2 format.
|
28
|
+
property :country_code
|
29
|
+
|
30
|
+
# The language associated with the merchant account, in BCP 47 format.
|
31
|
+
property :language_code
|
32
|
+
|
33
|
+
# The currency associated with the merchant account, in ISO 4217 format.
|
34
|
+
# For example, the currency code for US dollars is USD.
|
35
|
+
property :currency_code
|
36
|
+
|
37
|
+
# The name of the merchant's business.
|
38
|
+
property :business_name
|
39
|
+
|
40
|
+
# The address of the merchant's business.
|
41
|
+
property :business_address, coerce: Square::DataTypes::GlobalAddress
|
42
|
+
|
43
|
+
# The phone number of the merchant's business.
|
44
|
+
property :business_phone, coerce: Square::DataTypes::PhoneNumber
|
45
|
+
|
46
|
+
# The type of business operated by the merchant.
|
47
|
+
property :business_type # Merchant.BusinessType
|
48
|
+
|
49
|
+
# The merchant's shipping address.
|
50
|
+
property :shipping_address, coerce: Square::DataTypes::GlobalAddress
|
51
|
+
|
52
|
+
# Additional information for a single-location account specified by its
|
53
|
+
# associated business account, if it has one.
|
54
|
+
# Never included in Merchant objects with the account_typeBUSINESS.
|
55
|
+
property :location_details, coerce: Square::DataTypes::MerchantLocationDetails
|
56
|
+
|
57
|
+
# The URL of the merchant's online store.
|
58
|
+
property :market_url
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-merchantlocationdetails
|
4
|
+
class MerchantLocationDetails < Square::DataType
|
5
|
+
# The nickname assigned to the single-location account by the parent
|
6
|
+
# business. This value appears in the parent business's multi-location
|
7
|
+
# dashboard.
|
8
|
+
property :nickname
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-modifierlist
|
4
|
+
class ModifierList < Square::DataType
|
5
|
+
# The modifier list's unique ID.
|
6
|
+
property :id
|
7
|
+
|
8
|
+
# The modifier list's name.
|
9
|
+
property :name
|
10
|
+
|
11
|
+
# Indicates whether MULTIPLE options or a SINGLE option from the
|
12
|
+
# modifier list can be applied to a single item.
|
13
|
+
property :selection_type # ModifierList.SelectionType
|
14
|
+
|
15
|
+
# The options included in the modifier list.
|
16
|
+
property :modifier_options#, coerce: Array[Square::DataTypes::ModifierOption]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-modifieroption
|
4
|
+
class ModifierOption < Square::DataType
|
5
|
+
# The modifier option's unique ID.
|
6
|
+
property :id
|
7
|
+
|
8
|
+
# The modifier option's name.
|
9
|
+
property :name
|
10
|
+
|
11
|
+
# The modifier option's price.
|
12
|
+
property :price_money, coerce: Square::DataTypes::Money
|
13
|
+
|
14
|
+
# If true, the modifier option is the default option in a modifier
|
15
|
+
# list for which selection_type is SINGLE.
|
16
|
+
property :on_by_default # boolean
|
17
|
+
|
18
|
+
# Indicates the modifier option's list position when displayed in
|
19
|
+
# Square Register and the merchant dashboard. If more than one
|
20
|
+
# modifier option in the same modifier list has the same ordinal
|
21
|
+
# value, those options are displayed in alphabetical order.
|
22
|
+
# A modifier list's option with the lowest ordinal value is
|
23
|
+
# displayed first.
|
24
|
+
property :ordinal # number
|
25
|
+
|
26
|
+
# The ID of the modifier list the option belongs to.
|
27
|
+
property :modifier_list_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-money
|
4
|
+
class Money < Square::DataType
|
5
|
+
# The amount of money, in the smallest unit of the applicable currency.
|
6
|
+
# For US dollars, this value is in cents.
|
7
|
+
property :amount
|
8
|
+
|
9
|
+
# The type of currency involved in the current payment, in ISO 4217 format.
|
10
|
+
# For example, the currency code for US dollars is USD.
|
11
|
+
property :currency_code
|
12
|
+
|
13
|
+
# Initialize.
|
14
|
+
#
|
15
|
+
# @param [Hash] Hash of amount and currency_code.
|
16
|
+
#
|
17
|
+
# You can also pass in the amount and currency code as separate arguments.
|
18
|
+
#
|
19
|
+
# Example
|
20
|
+
#
|
21
|
+
# a = Square::DataTypes::Money.new(1)
|
22
|
+
# b = Square::DataTypes::Money.new({amount: 1, currency_code: 'USD'})
|
23
|
+
# a == b
|
24
|
+
# #=> true
|
25
|
+
#
|
26
|
+
# @return [Square::DataTypes::Money]
|
27
|
+
def initialize(*args)
|
28
|
+
if args.count == 1 && args.first.is_a?(Hash)
|
29
|
+
data = args.first
|
30
|
+
else
|
31
|
+
# Should this really even have a default?
|
32
|
+
code = args[1] || 'USD'
|
33
|
+
data = {amount: args[0], currency_code: code}
|
34
|
+
end
|
35
|
+
|
36
|
+
super(data)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
class Payment < Square::DataType
|
4
|
+
# The payment's unique identifier.
|
5
|
+
property :id
|
6
|
+
|
7
|
+
# The unique identifier of the merchant that took the payment.
|
8
|
+
property :merchant_id
|
9
|
+
|
10
|
+
# The time when the payment was created, in ISO 8601 format.
|
11
|
+
property :created_at
|
12
|
+
|
13
|
+
# The unique identifier of the Square account that took the payment.
|
14
|
+
# This value can differ from merchant_id if the merchant has mobile staff.
|
15
|
+
property :creator_id
|
16
|
+
|
17
|
+
# The device that took the payment.
|
18
|
+
property :device, coerce: Square::DataTypes::Device
|
19
|
+
|
20
|
+
# The URL of the payment's detail page in the merchant dashboard.
|
21
|
+
# The merchant must be signed in to the merchant dashboard to view
|
22
|
+
# this page.
|
23
|
+
property :payment_url
|
24
|
+
|
25
|
+
# The URL of the receipt for the payment.
|
26
|
+
# Note that for split tender payments, this URL corresponds to the receipt
|
27
|
+
# for the first tender listed in the payment's tender field. Each
|
28
|
+
# Tender object has its own receipt_url field you can use to get the
|
29
|
+
# other receipts associated with a split tender payment.
|
30
|
+
property :receipt_url
|
31
|
+
|
32
|
+
# The sum of all inclusive taxes associated with the payment.
|
33
|
+
property :inclusive_tax_money, coerce: Square::DataTypes::Money
|
34
|
+
|
35
|
+
# The sum of all additive taxes associated with the payment.
|
36
|
+
property :additive_tax_money, coerce: Square::DataTypes::Money
|
37
|
+
|
38
|
+
# The total of all taxes applied to the payment.
|
39
|
+
# This is always the sum of inclusive_tax_money and additive_tax_money.
|
40
|
+
property :tax_money, coerce: Square::DataTypes::Money
|
41
|
+
|
42
|
+
# The total of all tips applied to the payment.
|
43
|
+
property :tip_money, coerce: Square::DataTypes::Money
|
44
|
+
|
45
|
+
# The total of all discounts applied to the payment.
|
46
|
+
# This value is always 0 or negative.
|
47
|
+
property :discount_money, coerce: Square::DataTypes::Money
|
48
|
+
|
49
|
+
# The total amount of money collected from the buyer for the payment.
|
50
|
+
property :total_collected_money, coerce: Square::DataTypes::Money
|
51
|
+
|
52
|
+
# The total of all processing fees collected by Square for the payment.
|
53
|
+
# This value is always 0 or negative.
|
54
|
+
property :processing_fee_money, coerce: Square::DataTypes::Money
|
55
|
+
|
56
|
+
# The amount to be deposited into the merchant's bank account for
|
57
|
+
# the payment.
|
58
|
+
# This is always the sum of total_collected_money and processing_fee_money
|
59
|
+
# (note that processing_fee_money is always negative or 0).
|
60
|
+
property :net_total_money, coerce: Square::DataTypes::Money
|
61
|
+
|
62
|
+
# The total of all refunds applied to the payment.
|
63
|
+
property :refunded_money, coerce: Square::DataTypes::Money
|
64
|
+
|
65
|
+
# All of the inclusive taxes associated with the payment.
|
66
|
+
property :inclusive_tax, coerce: Array[Square::DataTypes::PaymentTax]
|
67
|
+
|
68
|
+
# All of the additive taxes associated with the payment.
|
69
|
+
property :additive_tax, coerce: Array[Square::DataTypes::PaymentTax]
|
70
|
+
|
71
|
+
# The form(s) of tender provided by the buyer for the payment.
|
72
|
+
property :tender, coerce: Array[Square::DataTypes::Tender]
|
73
|
+
|
74
|
+
# All of the refunds applied to the payment.
|
75
|
+
property :refunds, coerce: Array[Square::DataTypes::Refund]
|
76
|
+
|
77
|
+
# The items purchased in the payment.
|
78
|
+
property :itemizations, coerce: Array[Square::DataTypes::PaymentItemization]
|
79
|
+
|
80
|
+
# undocumented
|
81
|
+
property :gross_sales_money
|
82
|
+
property :swedish_rounding_money
|
83
|
+
property :net_sales_money
|
84
|
+
property :extensions
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-paymentdiscount
|
4
|
+
class PaymentDiscount < DataType
|
5
|
+
# The discount's name.
|
6
|
+
property :name
|
7
|
+
|
8
|
+
# The amount of money that this discount adds to the payment (note that
|
9
|
+
# this value is always negative or zero).
|
10
|
+
property :applied_money, coerce: Square::DataTypes::Money
|
11
|
+
|
12
|
+
# The ID of the applied discount, if available. Discounts applied in older
|
13
|
+
# versions of Square Register might not have an ID.
|
14
|
+
property :discount_id
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-paymentitemdetail
|
4
|
+
class PaymentItemDetail < DataType
|
5
|
+
# The name of the item's merchant-defined category, if any.
|
6
|
+
property :category_name
|
7
|
+
|
8
|
+
# The item's merchant-defined SKU, if any.
|
9
|
+
property :sku
|
10
|
+
|
11
|
+
# The unique ID of the item purchased, if any.
|
12
|
+
property :item_id
|
13
|
+
|
14
|
+
# The unique ID of the item variation purchased, if any.
|
15
|
+
property :item_variation_id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-paymentitemization
|
4
|
+
class PaymentItemization < DataType
|
5
|
+
# The item's name.
|
6
|
+
property :name
|
7
|
+
|
8
|
+
# The quantity of the item purchased. This can be a decimal value.
|
9
|
+
property :quantity, coerce: Integer
|
10
|
+
|
11
|
+
# The type of purchase that the itemization represents,
|
12
|
+
# such as an ITEM or CUSTOM_AMOUNT.
|
13
|
+
property :itemization_type # PaymentItemization.Type
|
14
|
+
|
15
|
+
# Details of the item, including its unique identifier and the identifier
|
16
|
+
# of the item variation purchased.
|
17
|
+
property :item_detail, coerce: Square::DataTypes::PaymentItemDetail
|
18
|
+
|
19
|
+
# Notes entered by the merchant about the item at the time of payment,
|
20
|
+
# if any.
|
21
|
+
property :notes
|
22
|
+
|
23
|
+
# The name of the item variation purchased, if any.
|
24
|
+
property :item_variation_name
|
25
|
+
|
26
|
+
# The total cost of the item, including all taxes and discounts.
|
27
|
+
property :total_money, coerce: Square::DataTypes::Money
|
28
|
+
|
29
|
+
# The cost of a single unit of this item.
|
30
|
+
property :single_quantity_money, coerce: Square::DataTypes::Money
|
31
|
+
|
32
|
+
# The total cost of the itemization and its modifiers, not including
|
33
|
+
# taxes or discounts.
|
34
|
+
property :gross_sales_money, coerce: Square::DataTypes::Money
|
35
|
+
|
36
|
+
# The total of all discounts applied to the itemization. This value is
|
37
|
+
# always negative or zero.
|
38
|
+
property :discount_money, coerce: Square::DataTypes::Money
|
39
|
+
|
40
|
+
# The sum of gross_sales_money and discount_money.
|
41
|
+
property :net_sales_money, coerce: Square::DataTypes::Money
|
42
|
+
|
43
|
+
# All taxes applied to this itemization.
|
44
|
+
property :taxes, coerce: Array[Square::DataTypes::PaymentTax]
|
45
|
+
|
46
|
+
# All discounts applied to this itemization.
|
47
|
+
property :discounts, coerce: Array[Square::DataTypes::PaymentDiscount]
|
48
|
+
|
49
|
+
# All modifier options applied to this itemization.
|
50
|
+
property :modifiers, coerce: Array[Square::DataTypes::PaymentModifier]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-paymentmodifier
|
4
|
+
class PaymentModifier < DataType
|
5
|
+
# The modifier option's name.
|
6
|
+
property :name
|
7
|
+
|
8
|
+
# The amount of money that this modifier option adds to the payment.
|
9
|
+
property :applied_money, coerce: Square::DataTypes::Money
|
10
|
+
|
11
|
+
# The ID of the applied modifier option, if available. Modifier options
|
12
|
+
# applied in older versions of Square Register might not have an ID.
|
13
|
+
property :modifier_option_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Square
|
2
|
+
module DataTypes
|
3
|
+
# https://docs.connect.squareup.com/api/connect/v1/#datatype-paymenttax
|
4
|
+
class PaymentTax < DataType
|
5
|
+
# The merchant-defined name of the tax.
|
6
|
+
property :name
|
7
|
+
|
8
|
+
# The amount of money that this tax adds to the payment.
|
9
|
+
property :applied_money, coerce: Square::DataTypes::Money
|
10
|
+
|
11
|
+
# The rate of the tax, as a string representation of a decimal number.
|
12
|
+
# A value of 0.07 corresponds to a rate of 7%.
|
13
|
+
property :rate
|
14
|
+
|
15
|
+
# Whether the tax is an ADDITIVE tax or an INCLUSIVE tax.
|
16
|
+
property :inclusion_type # Fee.InclusionType
|
17
|
+
|
18
|
+
# The ID of the tax, if available. Taxes applied in older versions of
|
19
|
+
# Square Register might not have an ID.
|
20
|
+
property :fee_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|