Class: Square::GiftCardActivitiesApi
- Defined in:
- lib/square/api/gift_card_activities_api.rb
Overview
GiftCardActivitiesApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_gift_card_activity(body:) ⇒ ApiResponse
Creates a gift card activity to manage the balance or state of a [gift card]($m/GiftCard).
-
#list_gift_card_activities(gift_card_id: nil, type: nil, location_id: nil, begin_time: nil, end_time: nil, limit: nil, cursor: nil, sort_order: nil) ⇒ ApiResponse
Lists gift card activities.
Methods inherited from BaseApi
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from Square::BaseApi
Instance Method Details
#create_gift_card_activity(body:) ⇒ ApiResponse
Creates a gift card activity to manage the balance or state of a [gift card]($m/GiftCard). For example, create an ‘ACTIVATE` activity to activate a gift card with an initial balance before first use. containing the fields to POST for the request. See the corresponding object definition for field details.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/square/api/gift_card_activities_api.rb', line 82 def create_gift_card_activity(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/gift-cards/activities', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#list_gift_card_activities(gift_card_id: nil, type: nil, location_id: nil, begin_time: nil, end_time: nil, limit: nil, cursor: nil, sort_order: nil) ⇒ ApiResponse
Lists gift card activities. By default, you get gift card activities for all gift cards in the seller’s account. You can optionally specify query parameters to filter the list. For example, you can get a list of gift card activities for a gift card, for all gift cards in a specific region, or for activities within a time window. provided, the endpoint returns activities related to the specified gift card. Otherwise, the endpoint returns all gift card activities for the seller. [type](entity:GiftCardActivityType) is provided, the endpoint returns gift card activities of the specified type. Otherwise, the endpoint returns all types of gift card activities. provided, the endpoint returns gift card activities for the specified location. Otherwise, the endpoint returns gift card activities for all locations. beginning of the reporting period, in RFC 3339 format. This start time is inclusive. The default value is the current time minus one year. the reporting period, in RFC 3339 format. This end time is inclusive. The default value is the current time. endpoint returns the specified number of results (or fewer) per page. The maximum value is 100. The default value is 50. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion). a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. If a cursor is not provided, the endpoint returns the first page of the results. For more information, see [Pagination](developer.squareup.com/docs/working-with-apis/paginat ion). endpoint returns the activities, based on ‘created_at`. - `ASC` - Oldest to newest. - `DESC` - Newest to oldest (default).
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/square/api/gift_card_activities_api.rb', line 45 def list_gift_card_activities(gift_card_id: nil, type: nil, location_id: nil, begin_time: nil, end_time: nil, limit: nil, cursor: nil, sort_order: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/gift-cards/activities', 'default') .query_param(new_parameter(gift_card_id, key: 'gift_card_id')) .query_param(new_parameter(type, key: 'type')) .query_param(new_parameter(location_id, key: 'location_id')) .query_param(new_parameter(begin_time, key: 'begin_time')) .query_param(new_parameter(end_time, key: 'end_time')) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(sort_order, key: 'sort_order')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |