paid_ruby 0.1.1.pre.rc5 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f5fd3f258651c6fcbc104ccb8f04ad0ed5ed46062542cdfb78e256b852a6050
4
- data.tar.gz: fddebf19044b8972da342ff75de44a477de184e83ed245d059cd15eb57990edf
3
+ metadata.gz: e08b12d8087ea612ca1b405c5d6cfa6fab4374f4f89ad81df1a7042b31206c72
4
+ data.tar.gz: 7dd1f1ef4c71fe4dd19d3c34e6eacd051a95087b74ec5be2f610efe9608e2a55
5
5
  SHA512:
6
- metadata.gz: d02d7883423a408e7e1ac4ce2b696aa2b3b505e53c4240ee91bf3d2ebaf9689c20af937f295db9e596b026a35fa63ebcd8a31786f91bfc3245726ec360cc7248
7
- data.tar.gz: ca0acbe775e1647c6b204aa2c64e90bd0a082106b48f6dc39fba291d8d6fc39037dc413821c29935fac5c8af1f8bb02d6420993b61a99a84dcb9d1c42e56323c
6
+ metadata.gz: 6eed37d4f15ac6939c644a4c7db14fbcaeb3d5e9e67d16b983d3060790f0daeb6054b1e5beb0241470bdaeca393bdc119503dc2ffd893272e9d522c62031059c
7
+ data.tar.gz: 931419aa3d4767c1df1f7c0ca332db5e629b73f7d38b3f8cdc61463626c726476ac89f327434ecd08bebdc631c8dbcc726484b925a6d4f3a821695b5220a4684
data/lib/gemconfig.rb CHANGED
@@ -9,6 +9,5 @@ module Paid
9
9
  HOMEPAGE = "https://github.com/paid-ai/paid-ruby"
10
10
  SOURCE_CODE_URI = "https://github.com/paid-ai/paid-ruby"
11
11
  CHANGELOG_URI = "https://github.com/paid-ai/paid-ruby/blob/master/CHANGELOG.md"
12
- RUBY_VERSION = ">= 3.4.4"
13
12
  end
14
13
  end
@@ -60,7 +60,6 @@ end
60
60
  # @param description [String]
61
61
  # @param agent_code [String]
62
62
  # @param external_id [String]
63
- # @param active [Boolean]
64
63
  # @param request_options [Paid::RequestOptions]
65
64
  # @return [Paid::Agent]
66
65
  # @example
@@ -69,12 +68,8 @@ end
69
68
  # environment: Paid::Environment::PRODUCTION,
70
69
  # token: "YOUR_AUTH_TOKEN"
71
70
  # )
72
- # api.agents.create(
73
- # name: "Acme Agent",
74
- # description: "Acme Agent is an AI agent that does things.",
75
- # external_id: "acme-agent"
76
- # )
77
- def create(name:, description:, agent_code: nil, external_id: nil, active: nil, request_options: nil)
71
+ # api.agents.create(name: "name", description: "description")
72
+ def create(name:, description:, agent_code: nil, external_id: nil, request_options: nil)
78
73
  response = @request_client.conn.post do | req |
79
74
  unless request_options&.timeout_in_seconds.nil?
80
75
  req.options.timeout = request_options.timeout_in_seconds
@@ -86,7 +81,7 @@ end
86
81
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
87
82
  req.params = { **(request_options&.additional_query_parameters || {}) }.compact
88
83
  end
89
- req.body = { **(request_options&.additional_body_parameters || {}), name: name, description: description, agentCode: agent_code, externalId: external_id, active: active }.compact
84
+ req.body = { **(request_options&.additional_body_parameters || {}), name: name, description: description, agentCode: agent_code, externalId: external_id }.compact
90
85
  req.url "#{@request_client.get_url(request_options: request_options)}/agents"
91
86
  end
92
87
  Paid::Agent.from_json(json_object: response.body)
@@ -136,7 +131,7 @@ end
136
131
  # environment: Paid::Environment::PRODUCTION,
137
132
  # token: "YOUR_AUTH_TOKEN"
138
133
  # )
139
- # api.agents.update(agent_id: "agentId", request: { name: "Acme Agent (Updated)", agent_attributes: [{ name: "Emails sent signal", active: true, pricing: { event_name: "emails_sent", taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { "USD": { tiers: [{ min_quantity: 0, max_quantity: 10, unit_price: 100 }, { min_quantity: 11, max_quantity: 100, unit_price: 90 }, { min_quantity: 101, unit_price: 80 }] } } } }] })
134
+ # api.agents.update(agent_id: "agentId", request: { })
140
135
  def update(agent_id:, request:, request_options: nil)
141
136
  response = @request_client.conn.put do | req |
142
137
  unless request_options&.timeout_in_seconds.nil?
@@ -227,7 +222,7 @@ end
227
222
  # environment: Paid::Environment::PRODUCTION,
228
223
  # token: "YOUR_AUTH_TOKEN"
229
224
  # )
230
- # api.agents.update_by_external_id(external_id: "externalId", request: { name: "Acme Agent (Updated)", agent_attributes: [{ name: "Emails sent signal", active: true, pricing: { event_name: "emails_sent", taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { "USD": { unit_price: 150 } } } }] })
225
+ # api.agents.update_by_external_id(external_id: "externalId", request: { })
231
226
  def update_by_external_id(external_id:, request:, request_options: nil)
232
227
  response = @request_client.conn.put do | req |
233
228
  unless request_options&.timeout_in_seconds.nil?
@@ -322,7 +317,6 @@ end
322
317
  # @param description [String]
323
318
  # @param agent_code [String]
324
319
  # @param external_id [String]
325
- # @param active [Boolean]
326
320
  # @param request_options [Paid::RequestOptions]
327
321
  # @return [Paid::Agent]
328
322
  # @example
@@ -331,12 +325,8 @@ end
331
325
  # environment: Paid::Environment::PRODUCTION,
332
326
  # token: "YOUR_AUTH_TOKEN"
333
327
  # )
334
- # api.agents.create(
335
- # name: "Acme Agent",
336
- # description: "Acme Agent is an AI agent that does things.",
337
- # external_id: "acme-agent"
338
- # )
339
- def create(name:, description:, agent_code: nil, external_id: nil, active: nil, request_options: nil)
328
+ # api.agents.create(name: "name", description: "description")
329
+ def create(name:, description:, agent_code: nil, external_id: nil, request_options: nil)
340
330
  Async do
341
331
  response = @request_client.conn.post do | req |
342
332
  unless request_options&.timeout_in_seconds.nil?
@@ -349,7 +339,7 @@ end
349
339
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
350
340
  req.params = { **(request_options&.additional_query_parameters || {}) }.compact
351
341
  end
352
- req.body = { **(request_options&.additional_body_parameters || {}), name: name, description: description, agentCode: agent_code, externalId: external_id, active: active }.compact
342
+ req.body = { **(request_options&.additional_body_parameters || {}), name: name, description: description, agentCode: agent_code, externalId: external_id }.compact
353
343
  req.url "#{@request_client.get_url(request_options: request_options)}/agents"
354
344
  end
355
345
  Paid::Agent.from_json(json_object: response.body)
@@ -402,7 +392,7 @@ end
402
392
  # environment: Paid::Environment::PRODUCTION,
403
393
  # token: "YOUR_AUTH_TOKEN"
404
394
  # )
405
- # api.agents.update(agent_id: "agentId", request: { name: "Acme Agent (Updated)", agent_attributes: [{ name: "Emails sent signal", active: true, pricing: { event_name: "emails_sent", taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { "USD": { tiers: [{ min_quantity: 0, max_quantity: 10, unit_price: 100 }, { min_quantity: 11, max_quantity: 100, unit_price: 90 }, { min_quantity: 101, unit_price: 80 }] } } } }] })
395
+ # api.agents.update(agent_id: "agentId", request: { })
406
396
  def update(agent_id:, request:, request_options: nil)
407
397
  Async do
408
398
  response = @request_client.conn.put do | req |
@@ -499,7 +489,7 @@ end
499
489
  # environment: Paid::Environment::PRODUCTION,
500
490
  # token: "YOUR_AUTH_TOKEN"
501
491
  # )
502
- # api.agents.update_by_external_id(external_id: "externalId", request: { name: "Acme Agent (Updated)", agent_attributes: [{ name: "Emails sent signal", active: true, pricing: { event_name: "emails_sent", taxable: true, charge_type: USAGE, pricing_model: PER_UNIT, billing_frequency: MONTHLY, price_points: { "USD": { unit_price: 150 } } } }] })
492
+ # api.agents.update_by_external_id(external_id: "externalId", request: { })
503
493
  def update_by_external_id(external_id:, request:, request_options: nil)
504
494
  Async do
505
495
  response = @request_client.conn.put do | req |
@@ -76,13 +76,16 @@ end
76
76
  # token: "YOUR_AUTH_TOKEN"
77
77
  # )
78
78
  # api.contacts.create(
79
- # customer_external_id: "acme-inc",
80
79
  # salutation: MR,
81
- # first_name: "John",
82
- # last_name: "Doe",
83
- # email: "john.doe@example.com"
80
+ # first_name: "firstName",
81
+ # last_name: "lastName",
82
+ # email: "email",
83
+ # billing_street: "billingStreet",
84
+ # billing_city: "billingCity",
85
+ # billing_country: "billingCountry",
86
+ # billing_postal_code: "billingPostalCode"
84
87
  # )
85
- def create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street: nil, billing_city: nil, billing_state_province: nil, billing_country: nil, billing_postal_code: nil, request_options: nil)
88
+ def create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street:, billing_city:, billing_state_province: nil, billing_country:, billing_postal_code:, request_options: nil)
86
89
  response = @request_client.conn.post do | req |
87
90
  unless request_options&.timeout_in_seconds.nil?
88
91
  req.options.timeout = request_options.timeout_in_seconds
@@ -280,13 +283,16 @@ end
280
283
  # token: "YOUR_AUTH_TOKEN"
281
284
  # )
282
285
  # api.contacts.create(
283
- # customer_external_id: "acme-inc",
284
286
  # salutation: MR,
285
- # first_name: "John",
286
- # last_name: "Doe",
287
- # email: "john.doe@example.com"
287
+ # first_name: "firstName",
288
+ # last_name: "lastName",
289
+ # email: "email",
290
+ # billing_street: "billingStreet",
291
+ # billing_city: "billingCity",
292
+ # billing_country: "billingCountry",
293
+ # billing_postal_code: "billingPostalCode"
288
294
  # )
289
- def create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street: nil, billing_city: nil, billing_state_province: nil, billing_country: nil, billing_postal_code: nil, request_options: nil)
295
+ def create(external_id: nil, customer_id: nil, customer_external_id: nil, salutation:, first_name:, last_name:, email:, phone: nil, billing_street:, billing_city:, billing_state_province: nil, billing_country:, billing_postal_code:, request_options: nil)
290
296
  Async do
291
297
  response = @request_client.conn.post do | req |
292
298
  unless request_options&.timeout_in_seconds.nil?
@@ -82,7 +82,7 @@ end
82
82
  # environment: Paid::Environment::PRODUCTION,
83
83
  # token: "YOUR_AUTH_TOKEN"
84
84
  # )
85
- # api.customers.create(name: "Acme, Inc.", external_id: "acme-inc")
85
+ # api.customers.create(name: "name")
86
86
  def create(name:, external_id: nil, phone: nil, employee_count: nil, annual_revenue: nil, tax_exempt_status: nil, creation_source: nil, website: nil, billing_address: nil, request_options: nil)
87
87
  response = @request_client.conn.post do | req |
88
88
  unless request_options&.timeout_in_seconds.nil?
@@ -154,7 +154,7 @@ end
154
154
  # environment: Paid::Environment::PRODUCTION,
155
155
  # token: "YOUR_AUTH_TOKEN"
156
156
  # )
157
- # api.customers.update(customer_id: "customerId", request: { name: "Acme, Inc. (Updated)", phone: "123-456-7890", employee_count: 101, annual_revenue: 1000001 })
157
+ # api.customers.update(customer_id: "customerId", request: { })
158
158
  def update(customer_id:, request:, request_options: nil)
159
159
  response = @request_client.conn.put do | req |
160
160
  unless request_options&.timeout_in_seconds.nil?
@@ -368,7 +368,7 @@ end
368
368
  # environment: Paid::Environment::PRODUCTION,
369
369
  # token: "YOUR_AUTH_TOKEN"
370
370
  # )
371
- # api.customers.create(name: "Acme, Inc.", external_id: "acme-inc")
371
+ # api.customers.create(name: "name")
372
372
  def create(name:, external_id: nil, phone: nil, employee_count: nil, annual_revenue: nil, tax_exempt_status: nil, creation_source: nil, website: nil, billing_address: nil, request_options: nil)
373
373
  Async do
374
374
  response = @request_client.conn.post do | req |
@@ -444,7 +444,7 @@ end
444
444
  # environment: Paid::Environment::PRODUCTION,
445
445
  # token: "YOUR_AUTH_TOKEN"
446
446
  # )
447
- # api.customers.update(customer_id: "customerId", request: { name: "Acme, Inc. (Updated)", phone: "123-456-7890", employee_count: 101, annual_revenue: 1000001 })
447
+ # api.customers.update(customer_id: "customerId", request: { })
448
448
  def update(customer_id:, request:, request_options: nil)
449
449
  Async do
450
450
  response = @request_client.conn.put do | req |
@@ -79,14 +79,13 @@ end
79
79
  # token: "YOUR_AUTH_TOKEN"
80
80
  # )
81
81
  # api.orders.create(
82
- # customer_external_id: "acme-inc",
83
- # name: "Acme Order",
84
- # description: "Acme Order is an order for Acme, Inc.",
85
- # start_date: "2025-01-01",
86
- # end_date: "2026-01-01",
87
- # currency: "USD"
82
+ # customer_id: "customerId",
83
+ # billing_contact_id: "billingContactId",
84
+ # name: "name",
85
+ # start_date: "startDate",
86
+ # currency: "currency"
88
87
  # )
89
- def create(customer_id: nil, customer_external_id: nil, billing_contact_id: nil, name:, description: nil, start_date:, end_date: nil, currency:, order_lines: nil, request_options: nil)
88
+ def create(customer_id:, customer_external_id: nil, billing_contact_id:, name:, description: nil, start_date:, end_date: nil, currency:, order_lines: nil, request_options: nil)
90
89
  response = @request_client.conn.post do | req |
91
90
  unless request_options&.timeout_in_seconds.nil?
92
91
  req.options.timeout = request_options.timeout_in_seconds
@@ -259,14 +258,13 @@ end
259
258
  # token: "YOUR_AUTH_TOKEN"
260
259
  # )
261
260
  # api.orders.create(
262
- # customer_external_id: "acme-inc",
263
- # name: "Acme Order",
264
- # description: "Acme Order is an order for Acme, Inc.",
265
- # start_date: "2025-01-01",
266
- # end_date: "2026-01-01",
267
- # currency: "USD"
261
+ # customer_id: "customerId",
262
+ # billing_contact_id: "billingContactId",
263
+ # name: "name",
264
+ # start_date: "startDate",
265
+ # currency: "currency"
268
266
  # )
269
- def create(customer_id: nil, customer_external_id: nil, billing_contact_id: nil, name:, description: nil, start_date:, end_date: nil, currency:, order_lines: nil, request_options: nil)
267
+ def create(customer_id:, customer_external_id: nil, billing_contact_id:, name:, description: nil, start_date:, end_date: nil, currency:, order_lines: nil, request_options: nil)
270
268
  Async do
271
269
  response = @request_client.conn.post do | req |
272
270
  unless request_options&.timeout_in_seconds.nil?
@@ -31,7 +31,7 @@ module Paid
31
31
  # environment: Paid::Environment::PRODUCTION,
32
32
  # token: "YOUR_AUTH_TOKEN"
33
33
  # )
34
- # api.orders.lines.update(order_id: "orderId", lines: [{ agent_external_id: "acme-agent", name: "Order Line One", description: "Order Line One is an order line for Acme, Inc." }, { agent_external_id: "acme-agent-2", name: "Order Line Two", description: "Order Line Two is an order line for Acme, Inc." }])
34
+ # api.orders.lines.update(order_id: "orderId")
35
35
  def update(order_id:, lines: nil, request_options: nil)
36
36
  response = @request_client.conn.put do | req |
37
37
  unless request_options&.timeout_in_seconds.nil?
@@ -74,7 +74,7 @@ end
74
74
  # environment: Paid::Environment::PRODUCTION,
75
75
  # token: "YOUR_AUTH_TOKEN"
76
76
  # )
77
- # api.orders.lines.update(order_id: "orderId", lines: [{ agent_external_id: "acme-agent", name: "Order Line One", description: "Order Line One is an order line for Acme, Inc." }, { agent_external_id: "acme-agent-2", name: "Order Line Two", description: "Order Line Two is an order line for Acme, Inc." }])
77
+ # api.orders.lines.update(order_id: "orderId")
78
78
  def update(order_id:, lines: nil, request_options: nil)
79
79
  Async do
80
80
  response = @request_client.conn.put do | req |
@@ -3,9 +3,9 @@
3
3
  module Paid
4
4
  class BillingFrequency
5
5
 
6
- MONTHLY = "monthly"
7
- QUARTERLY = "quarterly"
8
- ANNUAL = "annual"
6
+ MONTHLY = "Monthly"
7
+ QUARTERLY = "Quarterly"
8
+ ANNUAL = "Annual"
9
9
 
10
10
  end
11
11
  end
@@ -11,8 +11,6 @@ module Paid
11
11
  attr_reader :event_name
12
12
  # @return [Boolean]
13
13
  attr_reader :taxable
14
- # @return [Float]
15
- attr_reader :credit_cost
16
14
  # @return [Paid::ChargeType]
17
15
  attr_reader :charge_type
18
16
  # @return [Paid::PricingModelType]
@@ -31,23 +29,21 @@ module Paid
31
29
 
32
30
  # @param event_name [String]
33
31
  # @param taxable [Boolean]
34
- # @param credit_cost [Float]
35
32
  # @param charge_type [Paid::ChargeType]
36
33
  # @param pricing_model [Paid::PricingModelType]
37
34
  # @param billing_frequency [Paid::BillingFrequency]
38
35
  # @param price_points [Hash{String => Paid::AgentPricePoint}]
39
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
40
37
  # @return [Paid::Pricing]
41
- def initialize(event_name: OMIT, taxable:, credit_cost: OMIT, charge_type:, pricing_model:, billing_frequency:, price_points:, additional_properties: nil)
38
+ def initialize(event_name: OMIT, taxable:, charge_type:, pricing_model:, billing_frequency:, price_points:, additional_properties: nil)
42
39
  @event_name = event_name if event_name != OMIT
43
40
  @taxable = taxable
44
- @credit_cost = credit_cost if credit_cost != OMIT
45
41
  @charge_type = charge_type
46
42
  @pricing_model = pricing_model
47
43
  @billing_frequency = billing_frequency
48
44
  @price_points = price_points
49
45
  @additional_properties = additional_properties
50
- @_field_set = { "eventName": event_name, "taxable": taxable, "creditCost": credit_cost, "chargeType": charge_type, "pricingModel": pricing_model, "billingFrequency": billing_frequency, "pricePoints": price_points }.reject do | _k, v |
46
+ @_field_set = { "eventName": event_name, "taxable": taxable, "chargeType": charge_type, "pricingModel": pricing_model, "billingFrequency": billing_frequency, "pricePoints": price_points }.reject do | _k, v |
51
47
  v == OMIT
52
48
  end
53
49
  end
@@ -60,7 +56,6 @@ end
60
56
  parsed_json = JSON.parse(json_object)
61
57
  event_name = parsed_json["eventName"]
62
58
  taxable = parsed_json["taxable"]
63
- credit_cost = parsed_json["creditCost"]
64
59
  charge_type = parsed_json["chargeType"]
65
60
  pricing_model = parsed_json["pricingModel"]
66
61
  billing_frequency = parsed_json["billingFrequency"]
@@ -71,7 +66,6 @@ end
71
66
  new(
72
67
  event_name: event_name,
73
68
  taxable: taxable,
74
- credit_cost: credit_cost,
75
69
  charge_type: charge_type,
76
70
  pricing_model: pricing_model,
77
71
  billing_frequency: billing_frequency,
@@ -94,7 +88,6 @@ end
94
88
  def self.validate_raw(obj:)
95
89
  obj.event_name&.is_a?(String) != false || raise("Passed value for field obj.event_name is not the expected type, validation failed.")
96
90
  obj.taxable.is_a?(Boolean) != false || raise("Passed value for field obj.taxable is not the expected type, validation failed.")
97
- obj.credit_cost&.is_a?(Float) != false || raise("Passed value for field obj.credit_cost is not the expected type, validation failed.")
98
91
  obj.charge_type.is_a?(Paid::ChargeType) != false || raise("Passed value for field obj.charge_type is not the expected type, validation failed.")
99
92
  obj.pricing_model.is_a?(Paid::PricingModelType) != false || raise("Passed value for field obj.pricing_model is not the expected type, validation failed.")
100
93
  obj.billing_frequency.is_a?(Paid::BillingFrequency) != false || raise("Passed value for field obj.billing_frequency is not the expected type, validation failed.")
@@ -6,7 +6,6 @@ module Paid
6
6
  PER_UNIT = "PerUnit"
7
7
  VOLUME_PRICING = "VolumePricing"
8
8
  GRADUATED_PRICING = "GraduatedPricing"
9
- PREPAID_CREDITS = "PrepaidCredits"
10
9
 
11
10
  end
12
11
  end
@@ -8,8 +8,6 @@ module Paid
8
8
  attr_reader :event_name
9
9
  # @return [String]
10
10
  attr_reader :agent_id
11
- # @return [String]
12
- attr_reader :external_agent_id
13
11
  # @return [String]
14
12
  attr_reader :customer_id
15
13
  # @return [Hash{String => Object}]
@@ -24,19 +22,17 @@ module Paid
24
22
 
25
23
  # @param event_name [String]
26
24
  # @param agent_id [String]
27
- # @param external_agent_id [String]
28
25
  # @param customer_id [String]
29
26
  # @param data [Hash{String => Object}]
30
27
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
31
28
  # @return [Paid::Signal]
32
- def initialize(event_name: OMIT, agent_id: OMIT, external_agent_id: OMIT, customer_id: OMIT, data: OMIT, additional_properties: nil)
29
+ def initialize(event_name: OMIT, agent_id: OMIT, customer_id: OMIT, data: OMIT, additional_properties: nil)
33
30
  @event_name = event_name if event_name != OMIT
34
31
  @agent_id = agent_id if agent_id != OMIT
35
- @external_agent_id = external_agent_id if external_agent_id != OMIT
36
32
  @customer_id = customer_id if customer_id != OMIT
37
33
  @data = data if data != OMIT
38
34
  @additional_properties = additional_properties
39
- @_field_set = { "event_name": event_name, "agent_id": agent_id, "external_agent_id": external_agent_id, "customer_id": customer_id, "data": data }.reject do | _k, v |
35
+ @_field_set = { "event_name": event_name, "agent_id": agent_id, "customer_id": customer_id, "data": data }.reject do | _k, v |
40
36
  v == OMIT
41
37
  end
42
38
  end
@@ -49,13 +45,11 @@ end
49
45
  parsed_json = JSON.parse(json_object)
50
46
  event_name = parsed_json["event_name"]
51
47
  agent_id = parsed_json["agent_id"]
52
- external_agent_id = parsed_json["external_agent_id"]
53
48
  customer_id = parsed_json["customer_id"]
54
49
  data = parsed_json["data"]
55
50
  new(
56
51
  event_name: event_name,
57
52
  agent_id: agent_id,
58
- external_agent_id: external_agent_id,
59
53
  customer_id: customer_id,
60
54
  data: data,
61
55
  additional_properties: struct
@@ -76,7 +70,6 @@ end
76
70
  def self.validate_raw(obj:)
77
71
  obj.event_name&.is_a?(String) != false || raise("Passed value for field obj.event_name is not the expected type, validation failed.")
78
72
  obj.agent_id&.is_a?(String) != false || raise("Passed value for field obj.agent_id is not the expected type, validation failed.")
79
- obj.external_agent_id&.is_a?(String) != false || raise("Passed value for field obj.external_agent_id is not the expected type, validation failed.")
80
73
  obj.customer_id&.is_a?(String) != false || raise("Passed value for field obj.customer_id is not the expected type, validation failed.")
81
74
  obj.data&.is_a?(Hash) != false || raise("Passed value for field obj.data is not the expected type, validation failed.")
82
75
  end
@@ -19,7 +19,6 @@ module Paid
19
19
  # @param signals [Array<Hash>] Request of type Array<Paid::Signal>, as a Hash
20
20
  # * :event_name (String)
21
21
  # * :agent_id (String)
22
- # * :external_agent_id (String)
23
22
  # * :customer_id (String)
24
23
  # * :data (Hash{String => Object})
25
24
  # @param request_options [Paid::RequestOptions]
@@ -30,7 +29,7 @@ module Paid
30
29
  # environment: Paid::Environment::PRODUCTION,
31
30
  # token: "YOUR_AUTH_TOKEN"
32
31
  # )
33
- # api.usage.record_bulk(signals: [{ }, { }, { }])
32
+ # api.usage.record_bulk
34
33
  def record_bulk(signals: nil, request_options: nil)
35
34
  response = @request_client.conn.post do | req |
36
35
  unless request_options&.timeout_in_seconds.nil?
@@ -63,7 +62,6 @@ end
63
62
  # @param signals [Array<Hash>] Request of type Array<Paid::Signal>, as a Hash
64
63
  # * :event_name (String)
65
64
  # * :agent_id (String)
66
- # * :external_agent_id (String)
67
65
  # * :customer_id (String)
68
66
  # * :data (Hash{String => Object})
69
67
  # @param request_options [Paid::RequestOptions]
@@ -74,7 +72,7 @@ end
74
72
  # environment: Paid::Environment::PRODUCTION,
75
73
  # token: "YOUR_AUTH_TOKEN"
76
74
  # )
77
- # api.usage.record_bulk(signals: [{ }, { }, { }])
75
+ # api.usage.record_bulk
78
76
  def record_bulk(signals: nil, request_options: nil)
79
77
  Async do
80
78
  response = @request_client.conn.post do | req |
data/lib/paid_ruby.rb CHANGED
@@ -9,8 +9,6 @@ require_relative "paid_ruby/contacts/client"
9
9
  require_relative "paid_ruby/orders/client"
10
10
  require_relative "paid_ruby/usage/client"
11
11
  require_relative "extensions/batch"
12
- require_relative "paid_ruby/tracing/tracing"
13
- require_relative "paid_ruby/tracing/wrappers/open_ai_wrapper"
14
12
 
15
13
  module Paid
16
14
  class Client
@@ -46,19 +44,6 @@ module Paid
46
44
  @orders = Paid::OrdersClient.new(request_client: @request_client)
47
45
  @usage = Paid::BatchUsageClient.new(request_client: @request_client)
48
46
  end
49
-
50
- def initialize_tracing
51
- token = @request_client.token
52
- api_key = token.gsub(/^Bearer /, "")
53
- Paid::Tracing.initialize_tracing(api_key: api_key)
54
- end
55
-
56
- # @param external_customer_id [String]
57
- # @param args [Array]
58
- # @param block [Proc]
59
- def capture(*args, external_customer_id:, &block)
60
- Paid::Tracing.capture(*args, external_customer_id: external_customer_id, &block)
61
- end
62
47
  end
63
48
 
64
49
  class AsyncClient
@@ -94,18 +79,5 @@ module Paid
94
79
  @orders = Paid::AsyncOrdersClient.new(request_client: @async_request_client)
95
80
  @usage = Paid::AsyncBatchUsageClient.new(request_client: @async_request_client)
96
81
  end
97
-
98
- def initialize_tracing
99
- token = @async_request_client.token
100
- api_key = token.gsub(/^Bearer /, "")
101
- Paid::Tracing.initialize_tracing(api_key: api_key)
102
- end
103
-
104
- # @param external_customer_id [String]
105
- # @param args [Array]
106
- # @param block [Proc]
107
- def capture(*args, external_customer_id:, &block)
108
- Paid::Tracing.capture(*args, external_customer_id: external_customer_id, &block)
109
- end
110
82
  end
111
83
  end
data/lib/requests.rb CHANGED
@@ -47,7 +47,7 @@ end
47
47
  end
48
48
  # @return [Hash{String => String}]
49
49
  def get_headers
50
- headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'paid_ruby', "X-Fern-SDK-Version": '0.1.1-rc5' }
50
+ headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'paid_ruby', "X-Fern-SDK-Version": '0.1.1' }
51
51
  headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
52
52
  headers
53
53
  end
@@ -92,7 +92,7 @@ end
92
92
  end
93
93
  # @return [Hash{String => String}]
94
94
  def get_headers
95
- headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'paid_ruby', "X-Fern-SDK-Version": '0.1.1-rc5' }
95
+ headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'paid_ruby', "X-Fern-SDK-Version": '0.1.1' }
96
96
  headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil?
97
97
  headers
98
98
  end
metadata CHANGED
@@ -1,70 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paid_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.pre.rc5
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-06-12 00:00:00.000000000 Z
11
12
  dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: opentelemetry-api
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - "~>"
17
- - !ruby/object:Gem::Version
18
- version: '1.5'
19
- type: :runtime
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - "~>"
24
- - !ruby/object:Gem::Version
25
- version: '1.5'
26
- - !ruby/object:Gem::Dependency
27
- name: opentelemetry-exporter-otlp
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - "~>"
31
- - !ruby/object:Gem::Version
32
- version: 0.30.0
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: 0.30.0
40
- - !ruby/object:Gem::Dependency
41
- name: opentelemetry-sdk
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.8'
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.8'
54
- - !ruby/object:Gem::Dependency
55
- name: ruby-openai
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '8.1'
61
- type: :runtime
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '8.1'
68
13
  - !ruby/object:Gem::Dependency
69
14
  name: faraday
70
15
  requirement: !ruby/object:Gem::Requirement
@@ -160,9 +105,6 @@ files:
160
105
  - lib/paid_ruby/customers/client.rb
161
106
  - lib/paid_ruby/orders/client.rb
162
107
  - lib/paid_ruby/orders/lines/client.rb
163
- - lib/paid_ruby/tracing/logging.rb
164
- - lib/paid_ruby/tracing/tracing.rb
165
- - lib/paid_ruby/tracing/wrappers/open_ai_wrapper.rb
166
108
  - lib/paid_ruby/types/address.rb
167
109
  - lib/paid_ruby/types/agent.rb
168
110
  - lib/paid_ruby/types/agent_attribute.rb
@@ -199,6 +141,7 @@ metadata:
199
141
  homepage_uri: https://github.com/paid-ai/paid-ruby
200
142
  source_code_uri: https://github.com/paid-ai/paid-ruby
201
143
  changelog_uri: https://github.com/paid-ai/paid-ruby/blob/master/CHANGELOG.md
144
+ post_install_message:
202
145
  rdoc_options: []
203
146
  require_paths:
204
147
  - lib
@@ -213,7 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
156
  - !ruby/object:Gem::Version
214
157
  version: '0'
215
158
  requirements: []
216
- rubygems_version: 3.6.7
159
+ rubygems_version: 3.1.6
160
+ signing_key:
217
161
  specification_version: 4
218
162
  summary: ''
219
163
  test_files: []
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "logger"
4
-
5
- module Paid
6
- module Tracing
7
- # Provides a central logger for the gem.
8
- # The log level can be configured via the PAID_LOG_LEVEL environment variable.
9
- # Supported levels are DEBUG, INFO, WARN, ERROR, FATAL.
10
- # If the variable is not set, the level defaults to FATAL to suppress output.
11
- module Logging
12
- def self.logger
13
- @logger ||= begin
14
- log_level_str = ENV["PAID_LOG_LEVEL"]&.upcase
15
- level = if log_level_str && Logger.const_defined?(log_level_str)
16
- Logger.const_get(log_level_str)
17
- else
18
- # Default to a level that shows no logs unless explicitly configured.
19
- Logger::FATAL
20
- end
21
-
22
- logger = Logger.new($stdout)
23
- logger.level = level
24
- logger.formatter = proc do |severity, _datetime, _progname, msg|
25
- "[Paid SDK] #{severity}: #{msg}\n"
26
- end
27
- logger
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "opentelemetry/sdk"
4
- require "opentelemetry/exporter/otlp"
5
- require_relative "logging"
6
-
7
- module Paid
8
- module Tracing
9
- @token = nil
10
-
11
- # Context keys to propagate external_customer_id and token to child spans.
12
- # These are just keys, not the values themselves.
13
- PAID_EXTERNAL_CUSTOMER_ID_KEY = OpenTelemetry::Context.create_key("paid.external_customer_id")
14
- PAID_TOKEN_KEY = OpenTelemetry::Context.create_key("paid.token")
15
-
16
- # @param api_key [String]
17
- def self.initialize_tracing(api_key:)
18
- endpoint = "https://collector.agentpaid.io:4318/v1/traces"
19
- # endpoint = "http://localhost:4318/v1/traces"
20
-
21
- @token = api_key
22
-
23
- exporter = OpenTelemetry::Exporter::OTLP::Exporter.new(
24
- endpoint: endpoint,
25
- headers: {}
26
- )
27
- span_processor = OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(exporter)
28
-
29
- OpenTelemetry::SDK.configure do |c|
30
- c.add_span_processor(span_processor)
31
- end
32
-
33
- # Add an at_exit hook to ensure spans are flushed before the script exits.
34
- at_exit do
35
- OpenTelemetry.tracer_provider.shutdown
36
- end
37
-
38
- Logging.logger.info("Paid tracing initialized successfully")
39
- rescue StandardError => e
40
- Logging.logger.error("Failed to initialize Paid tracing: #{e.message}")
41
- raise
42
- end
43
-
44
- def self.token
45
- @token
46
- end
47
-
48
- # Getter for the OpenAI wrapper to retrieve the external_customer_id from the context.
49
- def self.get_external_customer_id_from_context
50
- OpenTelemetry::Context.current.value(PAID_EXTERNAL_CUSTOMER_ID_KEY)
51
- end
52
-
53
- # Getter for the OpenAI wrapper to retrieve the token from the context.
54
- def self.get_token_from_context
55
- OpenTelemetry::Context.current.value(PAID_TOKEN_KEY)
56
- end
57
-
58
- # @param external_customer_id [String]
59
- # @param args [Array]
60
- # @param block [Proc]
61
- def self.capture(*args, external_customer_id:, &block)
62
- token = self.token
63
- unless token
64
- Logging.logger.warn("No token found - tracing is not initialized and will not be captured")
65
- return yield(*args) if block_given?
66
- end
67
-
68
- new_context_values = {
69
- PAID_EXTERNAL_CUSTOMER_ID_KEY => external_customer_id,
70
- PAID_TOKEN_KEY => token
71
- }
72
-
73
- # Execute the block within a new context containing our values.
74
- OpenTelemetry::Context.with_values(new_context_values) do
75
- tracer = OpenTelemetry.tracer_provider.tracer("paid.ruby")
76
-
77
- tracer.in_span("paid.ruby:#{external_customer_id}") do |span|
78
- span.set_attribute("external_customer_id", external_customer_id)
79
- span.set_attribute("token", token)
80
-
81
- begin
82
- result = yield(*args) if block_given?
83
- span.status = OpenTelemetry::Trace::Status.ok("Success")
84
- result
85
- rescue StandardError => e
86
- span.status = OpenTelemetry::Trace::Status.error("Error: #{e.message}")
87
- raise e
88
- end
89
- end
90
- end
91
- end
92
- end
93
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "openai"
4
- require_relative "../tracing"
5
-
6
- module Paid
7
- module Tracing
8
- module Wrappers
9
- # A wrapper around the OpenAI::Client that provides automatic tracing for API calls.
10
- class PaidOpenAI
11
- def initialize(openai_client:)
12
- @openai_client = openai_client
13
- @tracer = OpenTelemetry.tracer_provider.tracer("paid.ruby")
14
- end
15
-
16
- # Wraps the OpenAI#chat method to create a child span.
17
- def chat(parameters:)
18
- wrap_call(operation: "chat", model: parameters[:model]) do
19
- @openai_client.chat(parameters: parameters)
20
- end
21
- end
22
-
23
- # Wraps the OpenAI#embeddings method to create a child span.
24
- def embeddings(parameters:)
25
- wrap_call(operation: "embeddings", model: parameters[:model]) do
26
- @openai_client.embeddings(parameters: parameters)
27
- end
28
- end
29
-
30
- # Returns a wrapper for the images API.
31
- def images
32
- ImagesWrapper.new(openai_client: @openai_client, tracer: @tracer)
33
- end
34
-
35
- private
36
-
37
- # A private wrapper for the OpenAI Images API.
38
- class ImagesWrapper
39
- def initialize(openai_client:, tracer:)
40
- @openai_client = openai_client
41
- @tracer = tracer
42
- end
43
-
44
- def generate(parameters:)
45
- current_span = OpenTelemetry::Trace.current_span
46
- unless current_span.context.valid?
47
- Paid::Tracing::Logging.logger.warn("No active span found, calling OpenAI directly without tracing.")
48
- return @openai_client.images.generate(parameters: parameters)
49
- end
50
-
51
- external_customer_id = Paid::Tracing.get_external_customer_id_from_context
52
- token = Paid::Tracing.get_token_from_context
53
- model = parameters[:model] || "dall-e-3"
54
- span_name = "trace.images #{model}"
55
-
56
- @tracer.in_span(span_name) do |span|
57
- attributes = {
58
- "gen_ai.request.model" => model,
59
- "gen_ai.system" => "openai",
60
- "gen_ai.operation.name" => "image_generation"
61
- }
62
- attributes["external_customer_id"] = external_customer_id if external_customer_id
63
- attributes["token"] = token if token
64
- span.add_attributes(attributes)
65
-
66
- begin
67
- response = @openai_client.images.generate(parameters: parameters)
68
- span.add_attributes({
69
- "gen_ai.image.count" => parameters[:n] || 1,
70
- "gen_ai.image.size" => parameters[:size] || "1024x1024",
71
- "gen_ai.image.quality" => parameters[:quality] || "standard"
72
- })
73
- span.status = OpenTelemetry::Trace::Status.ok("Success")
74
- response
75
- rescue StandardError => e
76
- span.record_exception(e)
77
- span.status = OpenTelemetry::Trace::Status.error("Error: #{e.message}")
78
- raise e
79
- end
80
- end
81
- end
82
- end
83
-
84
- def wrap_call(operation:, model:, &block)
85
- current_span = OpenTelemetry::Trace.current_span
86
- unless current_span.context.valid?
87
- Paid::Tracing::Logging.logger.warn("No active span found, calling OpenAI directly without tracing.")
88
- return yield
89
- end
90
-
91
- external_customer_id = Paid::Tracing.get_external_customer_id_from_context
92
- token = Paid::Tracing.get_token_from_context
93
- model_name = model || "unknown"
94
- span_name = "trace.#{operation} #{model_name}"
95
-
96
- @tracer.in_span(span_name) do |span|
97
- attributes = {
98
- "gen_ai.system" => "openai",
99
- "gen_ai.operation.name" => operation
100
- }
101
- attributes["external_customer_id"] = external_customer_id if external_customer_id
102
- attributes["token"] = token if token
103
- span.add_attributes(attributes)
104
-
105
- begin
106
- response = yield
107
- add_response_attributes(span, response)
108
- span.status = OpenTelemetry::Trace::Status.ok("Success")
109
- response
110
- rescue StandardError => e
111
- span.record_exception(e)
112
- span.status = OpenTelemetry::Trace::Status.error("Error: #{e.message}")
113
- raise e
114
- end
115
- end
116
- end
117
-
118
- def add_response_attributes(span, response)
119
- return unless response.is_a?(Hash) && response.dig("usage")
120
-
121
- attributes = {
122
- "gen_ai.usage.input_tokens" => response.dig("usage", "prompt_tokens"),
123
- "gen_ai.usage.output_tokens" => response.dig("usage", "completion_tokens"),
124
- "gen_ai.response.model" => response.dig("model")
125
- }.compact
126
-
127
- span.add_attributes(attributes)
128
- end
129
- end
130
- end
131
- end
132
- end