Class: Square::Client
- Inherits:
-
Object
- Object
- Square::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/square/client.rb
Overview
square client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#apple_pay ⇒ ApplePayApi
Access to apple_pay controller.
-
#bank_accounts ⇒ BankAccountsApi
Access to bank_accounts controller.
-
#booking_custom_attributes ⇒ BookingCustomAttributesApi
Access to booking_custom_attributes controller.
-
#bookings ⇒ BookingsApi
Access to bookings controller.
-
#cards ⇒ CardsApi
Access to cards controller.
-
#cash_drawers ⇒ CashDrawersApi
Access to cash_drawers controller.
-
#catalog ⇒ CatalogApi
Access to catalog controller.
-
#checkout ⇒ CheckoutApi
Access to checkout controller.
-
#customer_custom_attributes ⇒ CustomerCustomAttributesApi
Access to customer_custom_attributes controller.
-
#customer_groups ⇒ CustomerGroupsApi
Access to customer_groups controller.
-
#customer_segments ⇒ CustomerSegmentsApi
Access to customer_segments controller.
-
#customers ⇒ CustomersApi
Access to customers controller.
-
#devices ⇒ DevicesApi
Access to devices controller.
-
#disputes ⇒ DisputesApi
Access to disputes controller.
-
#employees ⇒ EmployeesApi
Access to employees controller.
-
#events ⇒ EventsApi
Access to events controller.
-
#gift_card_activities ⇒ GiftCardActivitiesApi
Access to gift_card_activities controller.
-
#gift_cards ⇒ GiftCardsApi
Access to gift_cards controller.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: 'production', custom_url: 'https://connect.squareup.com', access_token: nil, bearer_auth_credentials: nil, square_version: '2024-11-20', user_agent_detail: '', additional_headers: {}, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#inventory ⇒ InventoryApi
Access to inventory controller.
-
#invoices ⇒ InvoicesApi
Access to invoices controller.
-
#labor ⇒ LaborApi
Access to labor controller.
-
#location_custom_attributes ⇒ LocationCustomAttributesApi
Access to location_custom_attributes controller.
-
#locations ⇒ LocationsApi
Access to locations controller.
-
#loyalty ⇒ LoyaltyApi
Access to loyalty controller.
-
#merchant_custom_attributes ⇒ MerchantCustomAttributesApi
Access to merchant_custom_attributes controller.
-
#merchants ⇒ MerchantsApi
Access to merchants controller.
-
#mobile_authorization ⇒ MobileAuthorizationApi
Access to mobile_authorization controller.
-
#o_auth ⇒ OAuthApi
Access to o_auth controller.
-
#order_custom_attributes ⇒ OrderCustomAttributesApi
Access to order_custom_attributes controller.
-
#orders ⇒ OrdersApi
Access to orders controller.
-
#payments ⇒ PaymentsApi
Access to payments controller.
-
#payouts ⇒ PayoutsApi
Access to payouts controller.
-
#refunds ⇒ RefundsApi
Access to refunds controller.
- #sdk_version ⇒ Object
-
#sites ⇒ SitesApi
Access to sites controller.
-
#snippets ⇒ SnippetsApi
Access to snippets controller.
- #square_version ⇒ Object
-
#subscriptions ⇒ SubscriptionsApi
Access to subscriptions controller.
-
#team ⇒ TeamApi
Access to team controller.
-
#terminal ⇒ TerminalApi
Access to terminal controller.
-
#transactions ⇒ TransactionsApi
Access to transactions controller.
- #user_agent_detail ⇒ Object
-
#v1_transactions ⇒ V1TransactionsApi
Access to v1_transactions controller.
-
#vendors ⇒ VendorsApi
Access to vendors controller.
-
#webhook_subscriptions ⇒ WebhookSubscriptionsApi
Access to webhook_subscriptions controller.
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: 'production', custom_url: 'https://connect.squareup.com', access_token: nil, bearer_auth_credentials: nil, square_version: '2024-11-20', user_agent_detail: '', additional_headers: {}, config: nil) ⇒ Client
Returns a new instance of Client.
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/square/client.rb', line 271 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, environment: 'production', custom_url: 'https://connect.squareup.com', access_token: nil, bearer_auth_credentials: nil, square_version: '2024-11-20', user_agent_detail: '', additional_headers: {}, config: nil ) @config = if config.nil? Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, environment: environment, custom_url: custom_url, access_token: access_token, bearer_auth_credentials: bearer_auth_credentials, square_version: square_version, user_agent_detail: user_agent_detail, additional_headers: additional_headers ) else config end custom_user_agent_parameters = { '{api-version}' => { 'value': @config.square_version, 'encode': false }, '{detail}' => { 'value': @config.user_agent_detail, 'encode': true } } user_agent_params = BaseApi.user_agent_parameters.merge!(custom_user_agent_parameters) @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .user_agent(BaseApi.user_agent, agent_parameters: user_agent_params) .additional_headers(@config.additional_headers) .global_header('Square-Version', @config.square_version) .symbolize_hash(true) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
5 6 7 |
# File 'lib/square/client.rb', line 5 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/square/client.rb', line 5 def config @config end |
Instance Method Details
#apple_pay ⇒ ApplePayApi
Access to apple_pay controller.
39 40 41 |
# File 'lib/square/client.rb', line 39 def apple_pay @apple_pay ||= ApplePayApi.new @global_configuration end |
#bank_accounts ⇒ BankAccountsApi
Access to bank_accounts controller.
45 46 47 |
# File 'lib/square/client.rb', line 45 def bank_accounts @bank_accounts ||= BankAccountsApi.new @global_configuration end |
#booking_custom_attributes ⇒ BookingCustomAttributesApi
Access to booking_custom_attributes controller.
57 58 59 |
# File 'lib/square/client.rb', line 57 def booking_custom_attributes @booking_custom_attributes ||= BookingCustomAttributesApi.new @global_configuration end |
#bookings ⇒ BookingsApi
Access to bookings controller.
51 52 53 |
# File 'lib/square/client.rb', line 51 def bookings @bookings ||= BookingsApi.new @global_configuration end |
#cards ⇒ CardsApi
Access to cards controller.
63 64 65 |
# File 'lib/square/client.rb', line 63 def cards @cards ||= CardsApi.new @global_configuration end |
#cash_drawers ⇒ CashDrawersApi
Access to cash_drawers controller.
69 70 71 |
# File 'lib/square/client.rb', line 69 def cash_drawers @cash_drawers ||= CashDrawersApi.new @global_configuration end |
#catalog ⇒ CatalogApi
Access to catalog controller.
75 76 77 |
# File 'lib/square/client.rb', line 75 def catalog @catalog ||= CatalogApi.new @global_configuration end |
#checkout ⇒ CheckoutApi
Access to checkout controller.
171 172 173 |
# File 'lib/square/client.rb', line 171 def checkout @checkout ||= CheckoutApi.new @global_configuration end |
#customer_custom_attributes ⇒ CustomerCustomAttributesApi
Access to customer_custom_attributes controller.
87 88 89 |
# File 'lib/square/client.rb', line 87 def customer_custom_attributes @customer_custom_attributes ||= CustomerCustomAttributesApi.new @global_configuration end |
#customer_groups ⇒ CustomerGroupsApi
Access to customer_groups controller.
93 94 95 |
# File 'lib/square/client.rb', line 93 def customer_groups @customer_groups ||= CustomerGroupsApi.new @global_configuration end |
#customer_segments ⇒ CustomerSegmentsApi
Access to customer_segments controller.
99 100 101 |
# File 'lib/square/client.rb', line 99 def customer_segments @customer_segments ||= CustomerSegmentsApi.new @global_configuration end |
#customers ⇒ CustomersApi
Access to customers controller.
81 82 83 |
# File 'lib/square/client.rb', line 81 def customers @customers ||= CustomersApi.new @global_configuration end |
#devices ⇒ DevicesApi
Access to devices controller.
105 106 107 |
# File 'lib/square/client.rb', line 105 def devices @devices ||= DevicesApi.new @global_configuration end |
#disputes ⇒ DisputesApi
Access to disputes controller.
111 112 113 |
# File 'lib/square/client.rb', line 111 def disputes @disputes ||= DisputesApi.new @global_configuration end |
#employees ⇒ EmployeesApi
Access to employees controller.
117 118 119 |
# File 'lib/square/client.rb', line 117 def employees @employees ||= EmployeesApi.new @global_configuration end |
#events ⇒ EventsApi
Access to events controller.
123 124 125 |
# File 'lib/square/client.rb', line 123 def events @events ||= EventsApi.new @global_configuration end |
#gift_card_activities ⇒ GiftCardActivitiesApi
Access to gift_card_activities controller.
135 136 137 |
# File 'lib/square/client.rb', line 135 def gift_card_activities @gift_card_activities ||= GiftCardActivitiesApi.new @global_configuration end |
#gift_cards ⇒ GiftCardsApi
Access to gift_cards controller.
129 130 131 |
# File 'lib/square/client.rb', line 129 def gift_cards @gift_cards ||= GiftCardsApi.new @global_configuration end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
319 320 321 322 323 324 |
# File 'lib/square/client.rb', line 319 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[global].each { |auth| @auth_managers[auth] = nil } @auth_managers['global'] = OAuth2.new(http_client_config.bearer_auth_credentials) end |
#inventory ⇒ InventoryApi
Access to inventory controller.
141 142 143 |
# File 'lib/square/client.rb', line 141 def inventory @inventory ||= InventoryApi.new @global_configuration end |
#invoices ⇒ InvoicesApi
Access to invoices controller.
147 148 149 |
# File 'lib/square/client.rb', line 147 def invoices @invoices ||= InvoicesApi.new @global_configuration end |
#labor ⇒ LaborApi
Access to labor controller.
153 154 155 |
# File 'lib/square/client.rb', line 153 def labor @labor ||= LaborApi.new @global_configuration end |
#location_custom_attributes ⇒ LocationCustomAttributesApi
Access to location_custom_attributes controller.
165 166 167 |
# File 'lib/square/client.rb', line 165 def location_custom_attributes @location_custom_attributes ||= LocationCustomAttributesApi.new @global_configuration end |
#locations ⇒ LocationsApi
Access to locations controller.
159 160 161 |
# File 'lib/square/client.rb', line 159 def locations @locations ||= LocationsApi.new @global_configuration end |
#loyalty ⇒ LoyaltyApi
Access to loyalty controller.
183 184 185 |
# File 'lib/square/client.rb', line 183 def loyalty @loyalty ||= LoyaltyApi.new @global_configuration end |
#merchant_custom_attributes ⇒ MerchantCustomAttributesApi
Access to merchant_custom_attributes controller.
195 196 197 |
# File 'lib/square/client.rb', line 195 def merchant_custom_attributes @merchant_custom_attributes ||= MerchantCustomAttributesApi.new @global_configuration end |
#merchants ⇒ MerchantsApi
Access to merchants controller.
189 190 191 |
# File 'lib/square/client.rb', line 189 def merchants @merchants ||= MerchantsApi.new @global_configuration end |
#mobile_authorization ⇒ MobileAuthorizationApi
Access to mobile_authorization controller.
21 22 23 |
# File 'lib/square/client.rb', line 21 def @mobile_authorization ||= MobileAuthorizationApi.new @global_configuration end |
#o_auth ⇒ OAuthApi
Access to o_auth controller.
27 28 29 |
# File 'lib/square/client.rb', line 27 def o_auth @o_auth ||= OAuthApi.new @global_configuration end |
#order_custom_attributes ⇒ OrderCustomAttributesApi
Access to order_custom_attributes controller.
207 208 209 |
# File 'lib/square/client.rb', line 207 def order_custom_attributes @order_custom_attributes ||= OrderCustomAttributesApi.new @global_configuration end |
#orders ⇒ OrdersApi
Access to orders controller.
201 202 203 |
# File 'lib/square/client.rb', line 201 def orders @orders ||= OrdersApi.new @global_configuration end |
#payments ⇒ PaymentsApi
Access to payments controller.
213 214 215 |
# File 'lib/square/client.rb', line 213 def payments @payments ||= PaymentsApi.new @global_configuration end |
#payouts ⇒ PayoutsApi
Access to payouts controller.
219 220 221 |
# File 'lib/square/client.rb', line 219 def payouts @payouts ||= PayoutsApi.new @global_configuration end |
#refunds ⇒ RefundsApi
Access to refunds controller.
225 226 227 |
# File 'lib/square/client.rb', line 225 def refunds @refunds ||= RefundsApi.new @global_configuration end |
#sdk_version ⇒ Object
7 8 9 |
# File 'lib/square/client.rb', line 7 def sdk_version '40.0.0.20241120' end |
#sites ⇒ SitesApi
Access to sites controller.
231 232 233 |
# File 'lib/square/client.rb', line 231 def sites @sites ||= SitesApi.new @global_configuration end |
#snippets ⇒ SnippetsApi
Access to snippets controller.
237 238 239 |
# File 'lib/square/client.rb', line 237 def snippets @snippets ||= SnippetsApi.new @global_configuration end |
#square_version ⇒ Object
11 12 13 |
# File 'lib/square/client.rb', line 11 def square_version config.square_version end |
#subscriptions ⇒ SubscriptionsApi
Access to subscriptions controller.
243 244 245 |
# File 'lib/square/client.rb', line 243 def subscriptions @subscriptions ||= SubscriptionsApi.new @global_configuration end |
#team ⇒ TeamApi
Access to team controller.
249 250 251 |
# File 'lib/square/client.rb', line 249 def team @team ||= TeamApi.new @global_configuration end |
#terminal ⇒ TerminalApi
Access to terminal controller.
255 256 257 |
# File 'lib/square/client.rb', line 255 def terminal @terminal ||= TerminalApi.new @global_configuration end |
#transactions ⇒ TransactionsApi
Access to transactions controller.
177 178 179 |
# File 'lib/square/client.rb', line 177 def transactions @transactions ||= TransactionsApi.new @global_configuration end |
#user_agent_detail ⇒ Object
15 16 17 |
# File 'lib/square/client.rb', line 15 def user_agent_detail config.user_agent_detail end |
#v1_transactions ⇒ V1TransactionsApi
Access to v1_transactions controller.
33 34 35 |
# File 'lib/square/client.rb', line 33 def v1_transactions @v1_transactions ||= V1TransactionsApi.new @global_configuration end |
#vendors ⇒ VendorsApi
Access to vendors controller.
261 262 263 |
# File 'lib/square/client.rb', line 261 def vendors @vendors ||= VendorsApi.new @global_configuration end |
#webhook_subscriptions ⇒ WebhookSubscriptionsApi
Access to webhook_subscriptions controller.
267 268 269 |
# File 'lib/square/client.rb', line 267 def webhook_subscriptions @webhook_subscriptions ||= WebhookSubscriptionsApi.new @global_configuration end |