stigg 0.1.0.pre.beta.34 → 0.1.0.pre.beta.35
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/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/stigg/models/v1/credits/consumption_consume_async_params.rb +116 -0
- data/lib/stigg/models/v1/credits/consumption_consume_async_response.rb +23 -0
- data/lib/stigg/models/v1/credits/consumption_consume_params.rb +102 -0
- data/lib/stigg/models/v1/credits/consumption_consume_response.rb +134 -0
- data/lib/stigg/resources/v1/credits/consumption.rb +94 -0
- data/lib/stigg/resources/v1/credits.rb +4 -0
- data/lib/stigg/version.rb +1 -1
- data/lib/stigg.rb +5 -0
- data/rbi/stigg/models/v1/credits/consumption_consume_async_params.rbi +214 -0
- data/rbi/stigg/models/v1/credits/consumption_consume_async_response.rbi +35 -0
- data/rbi/stigg/models/v1/credits/consumption_consume_params.rbi +166 -0
- data/rbi/stigg/models/v1/credits/consumption_consume_response.rbi +232 -0
- data/rbi/stigg/resources/v1/credits/consumption.rbi +91 -0
- data/rbi/stigg/resources/v1/credits.rbi +3 -0
- data/sig/stigg/models/v1/credits/consumption_consume_async_params.rbs +107 -0
- data/sig/stigg/models/v1/credits/consumption_consume_async_response.rbs +17 -0
- data/sig/stigg/models/v1/credits/consumption_consume_params.rbs +90 -0
- data/sig/stigg/models/v1/credits/consumption_consume_response.rbs +101 -0
- data/sig/stigg/resources/v1/credits/consumption.rbs +31 -0
- data/sig/stigg/resources/v1/credits.rbs +2 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37796b53d48cf3448b56cb9d463ed46c3308e729cf52f572513f959c7dacec50
|
|
4
|
+
data.tar.gz: 5d16deb29b585ff6bef9e6a996e39e53069a93fc0bd0c2dc00a4a4f5552d96c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8cdc6cb04e672018779405902befa35db1a420df3390f661dd126cc15ef9fc4b76c92dd3bedfb354814aecc51a8b5844181aa54b3bc00021d481260f6e1ded45
|
|
7
|
+
data.tar.gz: 37357f0095e9611dd9cf877b09bbb3bc908279bf4fda021cb07d431c2844ce509379648ff91bda4ddd7ae1722dc4c67d526a1f45085f000dc1a3a85d3154fe15
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.35 (2026-07-01)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-beta.34...v0.1.0-beta.35](https://github.com/stiggio/stigg-ruby/compare/v0.1.0-beta.34...v0.1.0-beta.35)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** add consumption sub-resource to credits ([91984a0](https://github.com/stiggio/stigg-ruby/commit/91984a0134e60ec1b03ed1c0ad34fdbdabea9426))
|
|
10
|
+
|
|
3
11
|
## 0.1.0-beta.34 (2026-06-30)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v0.1.0-beta.33...v0.1.0-beta.34](https://github.com/stiggio/stigg-ruby/compare/v0.1.0-beta.33...v0.1.0-beta.34)
|
data/README.md
CHANGED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stigg
|
|
4
|
+
module Models
|
|
5
|
+
module V1
|
|
6
|
+
module Credits
|
|
7
|
+
# @see Stigg::Resources::V1::Credits::Consumption#consume_async
|
|
8
|
+
class ConsumptionConsumeAsyncParams < Stigg::Internal::Type::BaseModel
|
|
9
|
+
extend Stigg::Internal::Type::RequestParameters::Converter
|
|
10
|
+
include Stigg::Internal::Type::RequestParameters
|
|
11
|
+
|
|
12
|
+
# @!attribute consumptions
|
|
13
|
+
# The credit consumptions to report (up to 1000)
|
|
14
|
+
#
|
|
15
|
+
# @return [Array<Stigg::Models::V1::Credits::ConsumptionConsumeAsyncParams::Consumption>]
|
|
16
|
+
required :consumptions,
|
|
17
|
+
-> { Stigg::Internal::Type::ArrayOf[Stigg::V1::Credits::ConsumptionConsumeAsyncParams::Consumption] }
|
|
18
|
+
|
|
19
|
+
# @!attribute x_account_id
|
|
20
|
+
#
|
|
21
|
+
# @return [String, nil]
|
|
22
|
+
optional :x_account_id, String
|
|
23
|
+
|
|
24
|
+
# @!attribute x_environment_id
|
|
25
|
+
#
|
|
26
|
+
# @return [String, nil]
|
|
27
|
+
optional :x_environment_id, String
|
|
28
|
+
|
|
29
|
+
# @!method initialize(consumptions:, x_account_id: nil, x_environment_id: nil, request_options: {})
|
|
30
|
+
# @param consumptions [Array<Stigg::Models::V1::Credits::ConsumptionConsumeAsyncParams::Consumption>] The credit consumptions to report (up to 1000)
|
|
31
|
+
#
|
|
32
|
+
# @param x_account_id [String]
|
|
33
|
+
#
|
|
34
|
+
# @param x_environment_id [String]
|
|
35
|
+
#
|
|
36
|
+
# @param request_options [Stigg::RequestOptions, Hash{Symbol=>Object}]
|
|
37
|
+
|
|
38
|
+
class Consumption < Stigg::Internal::Type::BaseModel
|
|
39
|
+
# @!attribute amount
|
|
40
|
+
# The amount of credits to consume
|
|
41
|
+
#
|
|
42
|
+
# @return [Float]
|
|
43
|
+
required :amount, Float
|
|
44
|
+
|
|
45
|
+
# @!attribute currency_id
|
|
46
|
+
# The credit currency to consume from (required)
|
|
47
|
+
#
|
|
48
|
+
# @return [String]
|
|
49
|
+
required :currency_id, String, api_name: :currencyId
|
|
50
|
+
|
|
51
|
+
# @!attribute customer_id
|
|
52
|
+
# The customer to consume credits from (required)
|
|
53
|
+
#
|
|
54
|
+
# @return [String]
|
|
55
|
+
required :customer_id, String, api_name: :customerId
|
|
56
|
+
|
|
57
|
+
# @!attribute idempotency_key
|
|
58
|
+
# A unique key used to deduplicate the consumption (required)
|
|
59
|
+
#
|
|
60
|
+
# @return [String]
|
|
61
|
+
required :idempotency_key, String, api_name: :idempotencyKey
|
|
62
|
+
|
|
63
|
+
# @!attribute created_at
|
|
64
|
+
# Optional timestamp the consumption is attributed to
|
|
65
|
+
#
|
|
66
|
+
# @return [Time, nil]
|
|
67
|
+
optional :created_at, Time, api_name: :createdAt
|
|
68
|
+
|
|
69
|
+
# @!attribute dimensions
|
|
70
|
+
# Optional dimensions describing the consumption
|
|
71
|
+
#
|
|
72
|
+
# @return [Hash{Symbol=>String, Float, Boolean}, nil]
|
|
73
|
+
optional :dimensions,
|
|
74
|
+
-> { Stigg::Internal::Type::HashOf[union: Stigg::V1::Credits::ConsumptionConsumeAsyncParams::Consumption::Dimension] }
|
|
75
|
+
|
|
76
|
+
# @!attribute resource_id
|
|
77
|
+
# Optional resource the consumption is attributed to
|
|
78
|
+
#
|
|
79
|
+
# @return [String, nil]
|
|
80
|
+
optional :resource_id, String, api_name: :resourceId
|
|
81
|
+
|
|
82
|
+
# @!method initialize(amount:, currency_id:, customer_id:, idempotency_key:, created_at: nil, dimensions: nil, resource_id: nil)
|
|
83
|
+
# Request body for consuming credits directly from a wallet
|
|
84
|
+
#
|
|
85
|
+
# @param amount [Float] The amount of credits to consume
|
|
86
|
+
#
|
|
87
|
+
# @param currency_id [String] The credit currency to consume from (required)
|
|
88
|
+
#
|
|
89
|
+
# @param customer_id [String] The customer to consume credits from (required)
|
|
90
|
+
#
|
|
91
|
+
# @param idempotency_key [String] A unique key used to deduplicate the consumption (required)
|
|
92
|
+
#
|
|
93
|
+
# @param created_at [Time] Optional timestamp the consumption is attributed to
|
|
94
|
+
#
|
|
95
|
+
# @param dimensions [Hash{Symbol=>String, Float, Boolean}] Optional dimensions describing the consumption
|
|
96
|
+
#
|
|
97
|
+
# @param resource_id [String] Optional resource the consumption is attributed to
|
|
98
|
+
|
|
99
|
+
module Dimension
|
|
100
|
+
extend Stigg::Internal::Type::Union
|
|
101
|
+
|
|
102
|
+
variant String
|
|
103
|
+
|
|
104
|
+
variant Float
|
|
105
|
+
|
|
106
|
+
variant Stigg::Internal::Type::Boolean
|
|
107
|
+
|
|
108
|
+
# @!method self.variants
|
|
109
|
+
# @return [Array(String, Float, Boolean)]
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stigg
|
|
4
|
+
module Models
|
|
5
|
+
module V1
|
|
6
|
+
module Credits
|
|
7
|
+
# @see Stigg::Resources::V1::Credits::Consumption#consume_async
|
|
8
|
+
class ConsumptionConsumeAsyncResponse < Stigg::Internal::Type::BaseModel
|
|
9
|
+
# @!attribute data
|
|
10
|
+
# Confirmation that the credit consumptions were accepted for processing
|
|
11
|
+
#
|
|
12
|
+
# @return [Object]
|
|
13
|
+
required :data, Stigg::Internal::Type::Unknown
|
|
14
|
+
|
|
15
|
+
# @!method initialize(data:)
|
|
16
|
+
# Response object
|
|
17
|
+
#
|
|
18
|
+
# @param data [Object] Confirmation that the credit consumptions were accepted for processing
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stigg
|
|
4
|
+
module Models
|
|
5
|
+
module V1
|
|
6
|
+
module Credits
|
|
7
|
+
# @see Stigg::Resources::V1::Credits::Consumption#consume
|
|
8
|
+
class ConsumptionConsumeParams < Stigg::Internal::Type::BaseModel
|
|
9
|
+
extend Stigg::Internal::Type::RequestParameters::Converter
|
|
10
|
+
include Stigg::Internal::Type::RequestParameters
|
|
11
|
+
|
|
12
|
+
# @!attribute amount
|
|
13
|
+
# The amount of credits to consume
|
|
14
|
+
#
|
|
15
|
+
# @return [Float]
|
|
16
|
+
required :amount, Float
|
|
17
|
+
|
|
18
|
+
# @!attribute currency_id
|
|
19
|
+
# The credit currency to consume from (required)
|
|
20
|
+
#
|
|
21
|
+
# @return [String]
|
|
22
|
+
required :currency_id, String, api_name: :currencyId
|
|
23
|
+
|
|
24
|
+
# @!attribute customer_id
|
|
25
|
+
# The customer to consume credits from (required)
|
|
26
|
+
#
|
|
27
|
+
# @return [String]
|
|
28
|
+
required :customer_id, String, api_name: :customerId
|
|
29
|
+
|
|
30
|
+
# @!attribute idempotency_key
|
|
31
|
+
# A unique key used to deduplicate the consumption (required)
|
|
32
|
+
#
|
|
33
|
+
# @return [String]
|
|
34
|
+
required :idempotency_key, String, api_name: :idempotencyKey
|
|
35
|
+
|
|
36
|
+
# @!attribute created_at
|
|
37
|
+
# Optional timestamp the consumption is attributed to
|
|
38
|
+
#
|
|
39
|
+
# @return [Time, nil]
|
|
40
|
+
optional :created_at, Time, api_name: :createdAt
|
|
41
|
+
|
|
42
|
+
# @!attribute dimensions
|
|
43
|
+
# Optional dimensions describing the consumption
|
|
44
|
+
#
|
|
45
|
+
# @return [Hash{Symbol=>String, Float, Boolean}, nil]
|
|
46
|
+
optional :dimensions,
|
|
47
|
+
-> { Stigg::Internal::Type::HashOf[union: Stigg::V1::Credits::ConsumptionConsumeParams::Dimension] }
|
|
48
|
+
|
|
49
|
+
# @!attribute resource_id
|
|
50
|
+
# Optional resource the consumption is attributed to
|
|
51
|
+
#
|
|
52
|
+
# @return [String, nil]
|
|
53
|
+
optional :resource_id, String, api_name: :resourceId
|
|
54
|
+
|
|
55
|
+
# @!attribute x_account_id
|
|
56
|
+
#
|
|
57
|
+
# @return [String, nil]
|
|
58
|
+
optional :x_account_id, String
|
|
59
|
+
|
|
60
|
+
# @!attribute x_environment_id
|
|
61
|
+
#
|
|
62
|
+
# @return [String, nil]
|
|
63
|
+
optional :x_environment_id, String
|
|
64
|
+
|
|
65
|
+
# @!method initialize(amount:, currency_id:, customer_id:, idempotency_key:, created_at: nil, dimensions: nil, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {})
|
|
66
|
+
# @param amount [Float] The amount of credits to consume
|
|
67
|
+
#
|
|
68
|
+
# @param currency_id [String] The credit currency to consume from (required)
|
|
69
|
+
#
|
|
70
|
+
# @param customer_id [String] The customer to consume credits from (required)
|
|
71
|
+
#
|
|
72
|
+
# @param idempotency_key [String] A unique key used to deduplicate the consumption (required)
|
|
73
|
+
#
|
|
74
|
+
# @param created_at [Time] Optional timestamp the consumption is attributed to
|
|
75
|
+
#
|
|
76
|
+
# @param dimensions [Hash{Symbol=>String, Float, Boolean}] Optional dimensions describing the consumption
|
|
77
|
+
#
|
|
78
|
+
# @param resource_id [String] Optional resource the consumption is attributed to
|
|
79
|
+
#
|
|
80
|
+
# @param x_account_id [String]
|
|
81
|
+
#
|
|
82
|
+
# @param x_environment_id [String]
|
|
83
|
+
#
|
|
84
|
+
# @param request_options [Stigg::RequestOptions, Hash{Symbol=>Object}]
|
|
85
|
+
|
|
86
|
+
module Dimension
|
|
87
|
+
extend Stigg::Internal::Type::Union
|
|
88
|
+
|
|
89
|
+
variant String
|
|
90
|
+
|
|
91
|
+
variant Float
|
|
92
|
+
|
|
93
|
+
variant Stigg::Internal::Type::Boolean
|
|
94
|
+
|
|
95
|
+
# @!method self.variants
|
|
96
|
+
# @return [Array(String, Float, Boolean)]
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stigg
|
|
4
|
+
module Models
|
|
5
|
+
module V1
|
|
6
|
+
module Credits
|
|
7
|
+
# @see Stigg::Resources::V1::Credits::Consumption#consume
|
|
8
|
+
class ConsumptionConsumeResponse < Stigg::Internal::Type::BaseModel
|
|
9
|
+
# @!attribute data
|
|
10
|
+
# Result of a synchronous direct credit consumption
|
|
11
|
+
#
|
|
12
|
+
# @return [Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data]
|
|
13
|
+
required :data, -> { Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data }
|
|
14
|
+
|
|
15
|
+
# @!method initialize(data:)
|
|
16
|
+
# Response object
|
|
17
|
+
#
|
|
18
|
+
# @param data [Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data] Result of a synchronous direct credit consumption
|
|
19
|
+
|
|
20
|
+
# @see Stigg::Models::V1::Credits::ConsumptionConsumeResponse#data
|
|
21
|
+
class Data < Stigg::Internal::Type::BaseModel
|
|
22
|
+
# @!attribute amount
|
|
23
|
+
# The amount of credits consumed
|
|
24
|
+
#
|
|
25
|
+
# @return [Float]
|
|
26
|
+
required :amount, Float
|
|
27
|
+
|
|
28
|
+
# @!attribute currency_id
|
|
29
|
+
# The credit currency the credits were consumed from
|
|
30
|
+
#
|
|
31
|
+
# @return [String]
|
|
32
|
+
required :currency_id, String, api_name: :currencyId
|
|
33
|
+
|
|
34
|
+
# @!attribute customer_id
|
|
35
|
+
# The customer the credits were consumed from
|
|
36
|
+
#
|
|
37
|
+
# @return [String]
|
|
38
|
+
required :customer_id, String, api_name: :customerId
|
|
39
|
+
|
|
40
|
+
# @!attribute timestamp
|
|
41
|
+
# The timestamp the consumption was attributed to
|
|
42
|
+
#
|
|
43
|
+
# @return [Time]
|
|
44
|
+
required :timestamp, Time
|
|
45
|
+
|
|
46
|
+
# @!attribute credit
|
|
47
|
+
# The optimistic credit balance after consumption (when sync credit consumption is
|
|
48
|
+
# enabled)
|
|
49
|
+
#
|
|
50
|
+
# @return [Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data::Credit, nil]
|
|
51
|
+
optional :credit, -> { Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data::Credit }, nil?: true
|
|
52
|
+
|
|
53
|
+
# @!attribute resource_id
|
|
54
|
+
# The resource the consumption was attributed to
|
|
55
|
+
#
|
|
56
|
+
# @return [String, nil]
|
|
57
|
+
optional :resource_id, String, api_name: :resourceId, nil?: true
|
|
58
|
+
|
|
59
|
+
# @!method initialize(amount:, currency_id:, customer_id:, timestamp:, credit: nil, resource_id: nil)
|
|
60
|
+
# Some parameter documentations has been truncated, see
|
|
61
|
+
# {Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data} for more details.
|
|
62
|
+
#
|
|
63
|
+
# Result of a synchronous direct credit consumption
|
|
64
|
+
#
|
|
65
|
+
# @param amount [Float] The amount of credits consumed
|
|
66
|
+
#
|
|
67
|
+
# @param currency_id [String] The credit currency the credits were consumed from
|
|
68
|
+
#
|
|
69
|
+
# @param customer_id [String] The customer the credits were consumed from
|
|
70
|
+
#
|
|
71
|
+
# @param timestamp [Time] The timestamp the consumption was attributed to
|
|
72
|
+
#
|
|
73
|
+
# @param credit [Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data::Credit, nil] The optimistic credit balance after consumption (when sync credit consumption is
|
|
74
|
+
#
|
|
75
|
+
# @param resource_id [String, nil] The resource the consumption was attributed to
|
|
76
|
+
|
|
77
|
+
# @see Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data#credit
|
|
78
|
+
class Credit < Stigg::Internal::Type::BaseModel
|
|
79
|
+
# @!attribute currency_id
|
|
80
|
+
# The credit currency identifier
|
|
81
|
+
#
|
|
82
|
+
# @return [String]
|
|
83
|
+
required :currency_id, String, api_name: :currencyId
|
|
84
|
+
|
|
85
|
+
# @!attribute current_usage
|
|
86
|
+
# The credits consumed (optimistic — includes not-yet-reconciled usage)
|
|
87
|
+
#
|
|
88
|
+
# @return [Float]
|
|
89
|
+
required :current_usage, Float, api_name: :currentUsage
|
|
90
|
+
|
|
91
|
+
# @!attribute timestamp
|
|
92
|
+
# The grant-version timestamp of this balance, used by the SDK for last-write-wins
|
|
93
|
+
# reconciliation
|
|
94
|
+
#
|
|
95
|
+
# @return [Time]
|
|
96
|
+
required :timestamp, Time
|
|
97
|
+
|
|
98
|
+
# @!attribute usage_limit
|
|
99
|
+
# The total credits granted
|
|
100
|
+
#
|
|
101
|
+
# @return [Float]
|
|
102
|
+
required :usage_limit, Float, api_name: :usageLimit
|
|
103
|
+
|
|
104
|
+
# @!attribute usage_period_end
|
|
105
|
+
# End of the current credit grant period (when recurring credits reset), if
|
|
106
|
+
# applicable
|
|
107
|
+
#
|
|
108
|
+
# @return [Time, nil]
|
|
109
|
+
optional :usage_period_end, Time, api_name: :usagePeriodEnd, nil?: true
|
|
110
|
+
|
|
111
|
+
# @!method initialize(currency_id:, current_usage:, timestamp:, usage_limit:, usage_period_end: nil)
|
|
112
|
+
# Some parameter documentations has been truncated, see
|
|
113
|
+
# {Stigg::Models::V1::Credits::ConsumptionConsumeResponse::Data::Credit} for more
|
|
114
|
+
# details.
|
|
115
|
+
#
|
|
116
|
+
# The optimistic credit balance after consumption (when sync credit consumption is
|
|
117
|
+
# enabled)
|
|
118
|
+
#
|
|
119
|
+
# @param currency_id [String] The credit currency identifier
|
|
120
|
+
#
|
|
121
|
+
# @param current_usage [Float] The credits consumed (optimistic — includes not-yet-reconciled usage)
|
|
122
|
+
#
|
|
123
|
+
# @param timestamp [Time] The grant-version timestamp of this balance, used by the SDK for last-write-wins
|
|
124
|
+
#
|
|
125
|
+
# @param usage_limit [Float] The total credits granted
|
|
126
|
+
#
|
|
127
|
+
# @param usage_period_end [Time, nil] End of the current credit grant period (when recurring credits reset), if applic
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stigg
|
|
4
|
+
module Resources
|
|
5
|
+
class V1
|
|
6
|
+
class Credits
|
|
7
|
+
class Consumption
|
|
8
|
+
# Some parameter documentations has been truncated, see
|
|
9
|
+
# {Stigg::Models::V1::Credits::ConsumptionConsumeParams} for more details.
|
|
10
|
+
#
|
|
11
|
+
# Consumes a specified amount of credits directly from a customer wallet, with no
|
|
12
|
+
# feature mapping. Returns the optimistic balance.
|
|
13
|
+
#
|
|
14
|
+
# @overload consume(amount:, currency_id:, customer_id:, idempotency_key:, created_at: nil, dimensions: nil, resource_id: nil, x_account_id: nil, x_environment_id: nil, request_options: {})
|
|
15
|
+
#
|
|
16
|
+
# @param amount [Float] Body param: The amount of credits to consume
|
|
17
|
+
#
|
|
18
|
+
# @param currency_id [String] Body param: The credit currency to consume from (required)
|
|
19
|
+
#
|
|
20
|
+
# @param customer_id [String] Body param: The customer to consume credits from (required)
|
|
21
|
+
#
|
|
22
|
+
# @param idempotency_key [String] Body param: A unique key used to deduplicate the consumption (required)
|
|
23
|
+
#
|
|
24
|
+
# @param created_at [Time] Body param: Optional timestamp the consumption is attributed to
|
|
25
|
+
#
|
|
26
|
+
# @param dimensions [Hash{Symbol=>String, Float, Boolean}] Body param: Optional dimensions describing the consumption
|
|
27
|
+
#
|
|
28
|
+
# @param resource_id [String] Body param: Optional resource the consumption is attributed to
|
|
29
|
+
#
|
|
30
|
+
# @param x_account_id [String] Header param: Account ID — optional when authenticating with a user JWT (Bearer
|
|
31
|
+
#
|
|
32
|
+
# @param x_environment_id [String] Header param: Environment ID — required when authenticating with a user JWT (Bea
|
|
33
|
+
#
|
|
34
|
+
# @param request_options [Stigg::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
35
|
+
#
|
|
36
|
+
# @return [Stigg::Models::V1::Credits::ConsumptionConsumeResponse]
|
|
37
|
+
#
|
|
38
|
+
# @see Stigg::Models::V1::Credits::ConsumptionConsumeParams
|
|
39
|
+
def consume(params)
|
|
40
|
+
parsed, options = Stigg::V1::Credits::ConsumptionConsumeParams.dump_request(params)
|
|
41
|
+
header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
|
|
42
|
+
@client.request(
|
|
43
|
+
method: :post,
|
|
44
|
+
path: "api/v1/credits/consumption",
|
|
45
|
+
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
46
|
+
body: parsed.except(*header_params.keys),
|
|
47
|
+
model: Stigg::Models::V1::Credits::ConsumptionConsumeResponse,
|
|
48
|
+
options: options
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Some parameter documentations has been truncated, see
|
|
53
|
+
# {Stigg::Models::V1::Credits::ConsumptionConsumeAsyncParams} for more details.
|
|
54
|
+
#
|
|
55
|
+
# Consumes credits directly from customer wallets asynchronously. Consumptions are
|
|
56
|
+
# reconciled asynchronously into the credit balances.
|
|
57
|
+
#
|
|
58
|
+
# @overload consume_async(consumptions:, x_account_id: nil, x_environment_id: nil, request_options: {})
|
|
59
|
+
#
|
|
60
|
+
# @param consumptions [Array<Stigg::Models::V1::Credits::ConsumptionConsumeAsyncParams::Consumption>] Body param: The credit consumptions to report (up to 1000)
|
|
61
|
+
#
|
|
62
|
+
# @param x_account_id [String] Header param: Account ID — optional when authenticating with a user JWT (Bearer
|
|
63
|
+
#
|
|
64
|
+
# @param x_environment_id [String] Header param: Environment ID — required when authenticating with a user JWT (Bea
|
|
65
|
+
#
|
|
66
|
+
# @param request_options [Stigg::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
67
|
+
#
|
|
68
|
+
# @return [Stigg::Models::V1::Credits::ConsumptionConsumeAsyncResponse]
|
|
69
|
+
#
|
|
70
|
+
# @see Stigg::Models::V1::Credits::ConsumptionConsumeAsyncParams
|
|
71
|
+
def consume_async(params)
|
|
72
|
+
parsed, options = Stigg::V1::Credits::ConsumptionConsumeAsyncParams.dump_request(params)
|
|
73
|
+
header_params = {x_account_id: "x-account-id", x_environment_id: "x-environment-id"}
|
|
74
|
+
@client.request(
|
|
75
|
+
method: :post,
|
|
76
|
+
path: "api/v1/credits/consumption/async",
|
|
77
|
+
headers: parsed.slice(*header_params.keys).transform_keys(header_params),
|
|
78
|
+
body: parsed.except(*header_params.keys),
|
|
79
|
+
model: Stigg::Models::V1::Credits::ConsumptionConsumeAsyncResponse,
|
|
80
|
+
options: options
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# @api private
|
|
85
|
+
#
|
|
86
|
+
# @param client [Stigg::Client]
|
|
87
|
+
def initialize(client:)
|
|
88
|
+
@client = client
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -12,6 +12,9 @@ module Stigg
|
|
|
12
12
|
# @return [Stigg::Resources::V1::Credits::CustomCurrencies]
|
|
13
13
|
attr_reader :custom_currencies
|
|
14
14
|
|
|
15
|
+
# @return [Stigg::Resources::V1::Credits::Consumption]
|
|
16
|
+
attr_reader :consumption
|
|
17
|
+
|
|
15
18
|
# Some parameter documentations has been truncated, see
|
|
16
19
|
# {Stigg::Models::V1::CreditGetAutoRechargeParams} for more details.
|
|
17
20
|
#
|
|
@@ -181,6 +184,7 @@ module Stigg
|
|
|
181
184
|
@client = client
|
|
182
185
|
@grants = Stigg::Resources::V1::Credits::Grants.new(client: client)
|
|
183
186
|
@custom_currencies = Stigg::Resources::V1::Credits::CustomCurrencies.new(client: client)
|
|
187
|
+
@consumption = Stigg::Resources::V1::Credits::Consumption.new(client: client)
|
|
184
188
|
end
|
|
185
189
|
end
|
|
186
190
|
end
|
data/lib/stigg/version.rb
CHANGED
data/lib/stigg.rb
CHANGED
|
@@ -87,6 +87,10 @@ require_relative "stigg/models/v1/credit_get_usage_params"
|
|
|
87
87
|
require_relative "stigg/models/v1/credit_get_usage_response"
|
|
88
88
|
require_relative "stigg/models/v1/credit_list_ledger_params"
|
|
89
89
|
require_relative "stigg/models/v1/credit_list_ledger_response"
|
|
90
|
+
require_relative "stigg/models/v1/credits/consumption_consume_async_params"
|
|
91
|
+
require_relative "stigg/models/v1/credits/consumption_consume_async_response"
|
|
92
|
+
require_relative "stigg/models/v1/credits/consumption_consume_params"
|
|
93
|
+
require_relative "stigg/models/v1/credits/consumption_consume_response"
|
|
90
94
|
require_relative "stigg/models/v1/credits/credit_grant_response"
|
|
91
95
|
require_relative "stigg/models/v1/credits/custom_currency_archive_params"
|
|
92
96
|
require_relative "stigg/models/v1/credits/custom_currency_create_params"
|
|
@@ -241,6 +245,7 @@ require_relative "stigg/resources/v1/addons"
|
|
|
241
245
|
require_relative "stigg/resources/v1/addons/entitlements"
|
|
242
246
|
require_relative "stigg/resources/v1/coupons"
|
|
243
247
|
require_relative "stigg/resources/v1/credits"
|
|
248
|
+
require_relative "stigg/resources/v1/credits/consumption"
|
|
244
249
|
require_relative "stigg/resources/v1/credits/custom_currencies"
|
|
245
250
|
require_relative "stigg/resources/v1/credits/grants"
|
|
246
251
|
require_relative "stigg/resources/v1/customers"
|