Class: NewDemoApiClient::UnitEconomicsClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::UnitEconomicsClient
- Defined in:
- lib/test_sdk/unit_economics/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#get_contribution(group_id:, deal_id:, user_type:, freq: nil, request_options: nil) ⇒ Array<NewDemoApiClient::ContributionResponse>
Get the contribution for the user type.
- #initialize(request_client:) ⇒ NewDemoApiClient::UnitEconomicsClient constructor
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::UnitEconomicsClient
17 18 19 |
# File 'lib/test_sdk/unit_economics/client.rb', line 17 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::RequestClient (readonly)
13 14 15 |
# File 'lib/test_sdk/unit_economics/client.rb', line 13 def request_client @request_client end |
Instance Method Details
#get_contribution(group_id:, deal_id:, user_type:, freq: nil, request_options: nil) ⇒ Array<NewDemoApiClient::ContributionResponse>
Get the contribution for the user type.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/test_sdk/unit_economics/client.rb', line 40 def get_contribution(group_id:, deal_id:, user_type:, freq: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "user_type": user_type, "freq": freq }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/api/v1/group/#{group_id}/deal/#{deal_id}/data/contribution" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json NewDemoApiClient::ContributionResponse.from_json(json_object: item) end end |