Class: TrophyApiClient::Admin::Points::SystemsClient
- Inherits:
-
Object
- Object
- TrophyApiClient::Admin::Points::SystemsClient
- Defined in:
- lib/trophy_api_client/admin/points/systems/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreatePointsSystemsResponse
Create points systems.
-
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeletePointsSystemsResponse
Delete (archive) points systems by ID.
-
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminPointsSystem
Get a points system by ID.
- #initialize(request_client:) ⇒ TrophyApiClient::Admin::Points::SystemsClient constructor
-
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_POINTS_SYSTEMS_RESPONSE
List points systems.
-
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdatePointsSystemsResponse
Update points systems by ID.
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::Admin::Points::SystemsClient
23 24 25 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 23 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::RequestClient (readonly)
19 20 21 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 19 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreatePointsSystemsResponse
Create points systems. Optionally include sub-entities (levels, boosts,
triggers) in each system payload to create them alongside the system.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 79 def create(request:, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::CreatePointsSystemsResponse.from_json(json_object: response.body) end |
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeletePointsSystemsResponse
Delete (archive) points systems by ID.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 109 def delete(ids: nil, request_options: nil) response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "ids": ids }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::DeletePointsSystemsResponse.from_json(json_object: response.body) end |
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminPointsSystem
Get a points system by ID.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 169 def get(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points/#{id}" end TrophyApiClient::AdminPointsSystem.from_json(json_object: response.body) end |
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_POINTS_SYSTEMS_RESPONSE
List points systems.
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/trophy_api_client/admin/points/systems/client.rb', line 40 def list(limit: nil, skip: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "skip": skip }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::AdminPointsSystem.from_json(json_object: item) end end |
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdatePointsSystemsResponse
Update points systems by ID.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/trophy_api_client/admin/points/systems/client.rb', line 139 def update(request:, request_options: nil) response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/points" end TrophyApiClient::UpdatePointsSystemsResponse.from_json(json_object: response.body) end |