trophy_api_client 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/metrics/client.rb +14 -8
- data/lib/trophy_api_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39897ab7658149ab5f3bf2a97e23eb07e0f2a2e2e5efc65e44b3aa70ca4ca36b
|
4
|
+
data.tar.gz: c202d22246b40b860ea0e201b8f90df0379fbb2c0330913c89b44d969ddafc3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1716545b54c6ba34b2e33306d3ee3a6a2f638597898527c3df0ddeb200bd2a5686801661d41542bd36ebbf4cc005807bdcc81ab8c39f3cfc8de6dfccb423ae5
|
7
|
+
data.tar.gz: 5f6a490904fb8842edc52c718c3e1559d5c3d048a920cfa5e0d4255f8dce0d9c83b4d4ae3d199513f25cee5c52e38c101fc62b5887b8a6ce58f713a950b7e4aa
|
data/lib/gemconfig.rb
CHANGED
@@ -18,6 +18,7 @@ module TrophyApiClient
|
|
18
18
|
|
19
19
|
# Increment or decrement the value of a metric for a user.
|
20
20
|
#
|
21
|
+
# @param idempotency_key [String]
|
21
22
|
# @param key [String] Unique reference of the metric as set when created.
|
22
23
|
# @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::UpsertedUser, as a Hash
|
23
24
|
# * :id (String)
|
@@ -39,19 +40,21 @@ module TrophyApiClient
|
|
39
40
|
# api_key: "YOUR_API_KEY"
|
40
41
|
# )
|
41
42
|
# api.metrics.event(
|
43
|
+
# idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
|
42
44
|
# key: "words-written",
|
43
45
|
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
|
44
46
|
# value: 750,
|
45
47
|
# attributes: { "category": "writing", "source": "mobile-app" }
|
46
48
|
# )
|
47
|
-
def event(key:, user:, value:, attributes: nil, request_options: nil)
|
49
|
+
def event(key:, user:, value:, idempotency_key: nil, attributes: nil, request_options: nil)
|
48
50
|
response = @request_client.conn.post do |req|
|
49
51
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
50
52
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
51
53
|
req.headers = {
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
**(req.headers || {}),
|
55
|
+
**@request_client.get_headers,
|
56
|
+
**(request_options&.additional_headers || {}),
|
57
|
+
"Idempotency-Key": idempotency_key
|
55
58
|
}.compact
|
56
59
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
57
60
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|
@@ -80,6 +83,7 @@ module TrophyApiClient
|
|
80
83
|
|
81
84
|
# Increment or decrement the value of a metric for a user.
|
82
85
|
#
|
86
|
+
# @param idempotency_key [String]
|
83
87
|
# @param key [String] Unique reference of the metric as set when created.
|
84
88
|
# @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::UpsertedUser, as a Hash
|
85
89
|
# * :id (String)
|
@@ -101,20 +105,22 @@ module TrophyApiClient
|
|
101
105
|
# api_key: "YOUR_API_KEY"
|
102
106
|
# )
|
103
107
|
# api.metrics.event(
|
108
|
+
# idempotency_key: "e4296e4b-8493-4bd1-9c30-5a1a9ac4d78f",
|
104
109
|
# key: "words-written",
|
105
110
|
# user: { email: "user@example.com", tz: "Europe/London", attributes: { "department": "engineering", "role": "developer" }, id: "18" },
|
106
111
|
# value: 750,
|
107
112
|
# attributes: { "category": "writing", "source": "mobile-app" }
|
108
113
|
# )
|
109
|
-
def event(key:, user:, value:, attributes: nil, request_options: nil)
|
114
|
+
def event(key:, user:, value:, idempotency_key: nil, attributes: nil, request_options: nil)
|
110
115
|
Async do
|
111
116
|
response = @request_client.conn.post do |req|
|
112
117
|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
113
118
|
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
114
119
|
req.headers = {
|
115
|
-
|
116
|
-
|
117
|
-
|
120
|
+
**(req.headers || {}),
|
121
|
+
**@request_client.get_headers,
|
122
|
+
**(request_options&.additional_headers || {}),
|
123
|
+
"Idempotency-Key": idempotency_key
|
118
124
|
}.compact
|
119
125
|
unless request_options.nil? || request_options&.additional_query_parameters.nil?
|
120
126
|
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
|