Class: NewDemoApiClient::AsyncUnitEconomicsClient
- Inherits:
-
Object
- Object
- NewDemoApiClient::AsyncUnitEconomicsClient
- 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::AsyncUnitEconomicsClient constructor
Constructor Details
#initialize(request_client:) ⇒ NewDemoApiClient::AsyncUnitEconomicsClient
73 74 75 |
# File 'lib/test_sdk/unit_economics/client.rb', line 73 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ NewDemoApiClient::AsyncRequestClient (readonly)
69 70 71 |
# File 'lib/test_sdk/unit_economics/client.rb', line 69 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.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/test_sdk/unit_economics/client.rb', line 96 def get_contribution(group_id:, deal_id:, user_type:, freq: nil, request_options: nil) Async do 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 end |