Class: Square::Loyalty::Client
- Inherits:
-
Object
- Object
- Square::Loyalty::Client
- Defined in:
- lib/square/loyalty/client.rb
Instance Method Summary collapse
- #accounts ⇒ Square::Accounts::Client
- #initialize(client:) ⇒ Square::Loyalty::Client constructor
- #programs ⇒ Square::Programs::Client
- #rewards ⇒ Square::Rewards::Client
-
#search_events(request_options: {}, **params) ⇒ Square::Types::SearchLoyaltyEventsResponse
Searches for loyalty events.
Constructor Details
#initialize(client:) ⇒ Square::Loyalty::Client
7 8 9 |
# File 'lib/square/loyalty/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#accounts ⇒ Square::Accounts::Client
43 44 45 |
# File 'lib/square/loyalty/client.rb', line 43 def accounts @accounts ||= Square::Loyalty::Accounts::Client.new(client: @client) end |
#programs ⇒ Square::Programs::Client
48 49 50 |
# File 'lib/square/loyalty/client.rb', line 48 def programs @programs ||= Square::Loyalty::Programs::Client.new(client: @client) end |
#rewards ⇒ Square::Rewards::Client
53 54 55 |
# File 'lib/square/loyalty/client.rb', line 53 def rewards @rewards ||= Square::Loyalty::Rewards::Client.new(client: @client) end |
#search_events(request_options: {}, **params) ⇒ Square::Types::SearchLoyaltyEventsResponse
Searches for loyalty events.
A Square loyalty program maintains a ledger of events that occur during the lifetime of a buyer’s loyalty account. Each change in the point balance (for example, points earned, points redeemed, and points expired) is recorded in the ledger. Using this endpoint, you can search the ledger for events.
Search results are sorted by ‘created_at` in descending order.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/square/loyalty/client.rb', line 21 def search_events(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::PRODUCTION, method: "POST", path: "v2/loyalty/events/search", body: params ) begin _response = @client.send(_request) rescue Net::HTTPRequestTimeout raise Square::Errors::TimeoutError end code = _response.code.to_i if code.between?(200, 299) Square::Types::SearchLoyaltyEventsResponse.load(_response.body) else error_class = Square::Errors::ResponseError.subclass_for_code(code) raise error_class.new(_response.body, code: code) end end |