Class: Ifeelgoods::StatsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/ifeelgoods/api/stats_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ StatsApi

Returns a new instance of StatsApi.



19
20
21
# File 'lib/ifeelgoods/api/stats_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/ifeelgoods/api/stats_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_redemption_stats(client_id, opts = {}) ⇒ GetRedemptionStats200Response

Get Redemption Stats Use this function to access data relative to the reward delivery activity for a specific client

Parameters:

  • client_id (String)

    The client identifier

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :promotion_id (String)
  • :reward_sku (String)
  • :start_date (Time)

    ISO-8601 String representing the start date for the date range for which activity stats are extracted

  • :end_date (Time)

    ISO-8601 String representing the end date for the date range for which activity stats are extracted

  • :interval (String)

    Aggregation granularity - daily, monthly and yearly

  • :states (String)

    Filter to specify the state of the redemptions to include in the stats

Returns:



33
34
35
36
# File 'lib/ifeelgoods/api/stats_api.rb', line 33

def get_redemption_stats(client_id, opts = {})
  data, _status_code, _headers = get_redemption_stats_with_http_info(client_id, opts)
  data
end

#get_redemption_stats_with_http_info(client_id, opts = {}) ⇒ Array<(GetRedemptionStats200Response, Integer, Hash)>

Get Redemption Stats Use this function to access data relative to the reward delivery activity for a specific client

Parameters:

  • client_id (String)

    The client identifier

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :promotion_id (String)
  • :reward_sku (String)
  • :start_date (Time)

    ISO-8601 String representing the start date for the date range for which activity stats are extracted

  • :end_date (Time)

    ISO-8601 String representing the end date for the date range for which activity stats are extracted

  • :interval (String)

    Aggregation granularity - daily, monthly and yearly

  • :states (String)

    Filter to specify the state of the redemptions to include in the stats

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/ifeelgoods/api/stats_api.rb', line 49

def get_redemption_stats_with_http_info(client_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: StatsApi.get_redemption_stats ...'
  end
  # verify the required parameter 'client_id' is set
  if @api_client.config.client_side_validation && client_id.nil?
    fail ArgumentError, "Missing the required parameter 'client_id' when calling StatsApi.get_redemption_stats"
  end
  allowable_values = ["daily", "monthly", "yearly"]
  if @api_client.config.client_side_validation && opts[:'interval'] && !allowable_values.include?(opts[:'interval'])
    fail ArgumentError, "invalid value for \"interval\", must be one of #{allowable_values}"
  end
  allowable_values = ["all", "redeemed"]
  if @api_client.config.client_side_validation && opts[:'states'] && !allowable_values.include?(opts[:'states'])
    fail ArgumentError, "invalid value for \"states\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/fulfillment/v2/clients/{client_id}/stats'.sub('{client_id}', CGI.escape(client_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'promotion_id'] = opts[:'promotion_id'] if !opts[:'promotion_id'].nil?
  query_params[:'reward_sku'] = opts[:'reward_sku'] if !opts[:'reward_sku'].nil?
  query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'interval'] = opts[:'interval'] if !opts[:'interval'].nil?
  query_params[:'states'] = opts[:'states'] if !opts[:'states'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetRedemptionStats200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

  new_options = opts.merge(
    :operation => :"StatsApi.get_redemption_stats",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: StatsApi#get_redemption_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end