pingram 1.0.42 → 1.0.44

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.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/lib/pingram/api/account_api.rb +26 -0
  4. data/lib/pingram/api/accounts_api.rb +76 -0
  5. data/lib/pingram/api/broadcasts_api.rb +28 -0
  6. data/lib/pingram/api/default_api.rb +2 -0
  7. data/lib/pingram/api/domains_api.rb +12 -4
  8. data/lib/pingram/api/editor_api.rb +2 -0
  9. data/lib/pingram/api/email_api.rb +4 -0
  10. data/lib/pingram/api/environments_api.rb +2 -0
  11. data/lib/pingram/api/health_api.rb +2 -0
  12. data/lib/pingram/api/library_api.rb +4 -0
  13. data/lib/pingram/api/logs_api.rb +12 -0
  14. data/lib/pingram/api/members_api.rb +2 -0
  15. data/lib/pingram/api/numbers_api.rb +24 -2
  16. data/lib/pingram/api/registrations_api.rb +10 -0
  17. data/lib/pingram/api/sender_api.rb +2 -0
  18. data/lib/pingram/api/sms_api.rb +2 -0
  19. data/lib/pingram/api/sub_notifications_api.rb +4 -0
  20. data/lib/pingram/api/user_api.rb +6 -0
  21. data/lib/pingram/api/users_api.rb +2 -0
  22. data/lib/pingram/api/voice_api.rb +80 -0
  23. data/lib/pingram/api/webhooks_api.rb +8 -0
  24. data/lib/pingram/api_client.rb +1 -1
  25. data/lib/pingram/models/account_summary.rb +304 -0
  26. data/lib/pingram/models/agent.rb +10 -1
  27. data/lib/pingram/models/agent1.rb +10 -1
  28. data/lib/pingram/models/agent_agent_model.rb +2 -0
  29. data/lib/pingram/models/arm_voice_inbound_claim_request_inbound.rb +2 -0
  30. data/lib/pingram/models/brand_webhook_response.rb +1 -1
  31. data/lib/pingram/models/campaign_webhook_response.rb +1 -1
  32. data/lib/pingram/models/check_domain_dns_request.rb +148 -0
  33. data/lib/pingram/models/domain_dns_check_records_inner.rb +2 -2
  34. data/lib/pingram/models/elevenlabs.rb +207 -0
  35. data/lib/pingram/models/elevenlabs1.rb +207 -0
  36. data/lib/pingram/models/elevenlabs_eleven_realtime_v1_max.rb +251 -0
  37. data/lib/pingram/models/elevenlabs_eleven_realtime_v1_mini.rb +251 -0
  38. data/lib/pingram/models/get_senders_response_inner.rb +68 -4
  39. data/lib/pingram/models/get_senders_response_inner_verification_records.rb +13 -4
  40. data/lib/pingram/models/get_senders_response_inner_verification_records_dkim.rb +2 -2
  41. data/lib/pingram/models/get_voice_call_response_call.rb +30 -1
  42. data/lib/pingram/models/get_voice_call_response_call_setup.rb +252 -0
  43. data/lib/pingram/models/get_voice_call_response_call_setup_stream.rb +190 -0
  44. data/lib/pingram/models/google_gemini31_flash_live_preview.rb +22 -1
  45. data/lib/pingram/models/inbound_config.rb +2 -0
  46. data/lib/pingram/models/intercom_webhook.rb +1 -1
  47. data/lib/pingram/models/internal_transfer_body.rb +254 -0
  48. data/lib/pingram/models/internal_transfer_body_agent_meters_inner.rb +328 -0
  49. data/lib/pingram/models/list_voice_calls_response_calls_inner.rb +24 -4
  50. data/lib/pingram/models/member_update_request.rb +1 -1
  51. data/lib/pingram/models/openai_gpt_live1.rb +22 -1
  52. data/lib/pingram/models/openai_gpt_realtime21.rb +22 -1
  53. data/lib/pingram/models/openai_gpt_realtime21_mini.rb +22 -1
  54. data/lib/pingram/models/script.rb +10 -1
  55. data/lib/pingram/models/script1.rb +10 -1
  56. data/lib/pingram/models/script_privacy.rb +43 -8
  57. data/lib/pingram/models/script_stream.rb +193 -0
  58. data/lib/pingram/models/sign_in_username_response.rb +1 -1
  59. data/lib/pingram/models/sign_out_request.rb +1 -1
  60. data/lib/pingram/models/sms_compliance_countries_response_countries_inner.rb +1 -1
  61. data/lib/pingram/models/sms_compliance_country.rb +1 -1
  62. data/lib/pingram/models/stream.rb +207 -0
  63. data/lib/pingram/models/ten_dlc_brand_admin_update_request.rb +1 -1
  64. data/lib/pingram/models/transfer1.rb +40 -1
  65. data/lib/pingram/models/transfer_call_request.rb +196 -0
  66. data/lib/pingram/models/transfer_destinations_inner.rb +25 -56
  67. data/lib/pingram/models/update_account_request.rb +184 -0
  68. data/lib/pingram/models/voice_browser_call_request_config_any_of.rb +3 -1
  69. data/lib/pingram/models/voice_call_response.rb +32 -5
  70. data/lib/pingram/version.rb +1 -1
  71. data/lib/pingram.rb +14 -0
  72. data/vendor/bundle/ruby/3.2.0/cache/ethon-0.19.2.gem +0 -0
  73. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/CHANGELOG.md +45 -1
  74. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/README.md +55 -8
  75. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curl.rb +44 -0
  76. data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.2/lib/ethon/easy/form.rb +261 -0
  77. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/informations.rb +30 -0
  78. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/mirror.rb +7 -1
  79. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/options.rb +11 -7
  80. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/queryable.rb +5 -0
  81. data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.2/lib/ethon/errors/fork_safety.rb +10 -0
  82. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/libc.rb +5 -0
  83. data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.2/lib/ethon/multipart.rb +115 -0
  84. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/version.rb +1 -1
  85. data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon.rb +1 -0
  86. data/vendor/bundle/ruby/3.2.0/specifications/{ethon-0.19.1.gemspec → ethon-0.19.2.gemspec} +4 -4
  87. metadata +103 -88
  88. data/vendor/bundle/ruby/3.2.0/cache/ethon-0.19.1.gem +0 -0
  89. data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/form.rb +0 -166
  90. data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/fork_safety.rb +0 -10
  91. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/LICENSE +0 -0
  92. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/ethon.gemspec +0 -0
  93. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/classes.rb +0 -0
  94. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/codes.rb +0 -0
  95. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/constants.rb +0 -0
  96. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/form_options.rb +0 -0
  97. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/functions.rb +0 -0
  98. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/infos.rb +0 -0
  99. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/introspection.rb +0 -0
  100. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/introspection_constants.rb +0 -0
  101. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/messages.rb +0 -0
  102. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/mime.rb +0 -0
  103. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/optional.rb +0 -0
  104. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/options.rb +0 -0
  105. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/settings.rb +0 -0
  106. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/share.rb +0 -0
  107. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/share_constants.rb +0 -0
  108. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/url.rb +0 -0
  109. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/curls/url_constants.rb +0 -0
  110. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/callbacks.rb +0 -0
  111. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/debug_info.rb +0 -0
  112. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/features.rb +0 -0
  113. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/files.rb +0 -0
  114. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/header.rb +0 -0
  115. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/headers_api.rb +0 -0
  116. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/actionable.rb +0 -0
  117. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/custom.rb +0 -0
  118. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/delete.rb +0 -0
  119. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/get.rb +0 -0
  120. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/head.rb +0 -0
  121. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/options.rb +0 -0
  122. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/patch.rb +0 -0
  123. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/post.rb +0 -0
  124. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/postable.rb +0 -0
  125. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/put.rb +0 -0
  126. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http/putable.rb +0 -0
  127. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/http.rb +0 -0
  128. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/mime.rb +0 -0
  129. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/operations.rb +0 -0
  130. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/params.rb +0 -0
  131. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/response_callbacks.rb +0 -0
  132. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/share.rb +0 -0
  133. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/url.rb +0 -0
  134. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy/util.rb +0 -0
  135. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/easy.rb +0 -0
  136. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/ethon_error.rb +0 -0
  137. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/form_add.rb +0 -0
  138. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/global_init.rb +0 -0
  139. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/header.rb +0 -0
  140. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/invalid_option.rb +0 -0
  141. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/invalid_value.rb +0 -0
  142. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/mime.rb +0 -0
  143. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_add.rb +0 -0
  144. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_assign.rb +0 -0
  145. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_fdset.rb +0 -0
  146. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_perform.rb +0 -0
  147. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_poll.rb +0 -0
  148. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_remove.rb +0 -0
  149. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_timeout.rb +0 -0
  150. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_wait.rb +0 -0
  151. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/multi_wakeup.rb +0 -0
  152. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/select.rb +0 -0
  153. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/set_option.rb +0 -0
  154. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/share.rb +0 -0
  155. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/unsupported_option.rb +0 -0
  156. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors/url.rb +0 -0
  157. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/errors.rb +0 -0
  158. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/loggable.rb +0 -0
  159. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/multi/operations.rb +0 -0
  160. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/multi/options.rb +0 -0
  161. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/multi/stack.rb +0 -0
  162. /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.19.1 → ethon-0.19.2}/lib/ethon/multi.rb +0 -0
@@ -0,0 +1,261 @@
1
+ # frozen_string_literal: true
2
+ require 'ethon/easy/util'
3
+ require 'ethon/easy/queryable'
4
+
5
+ module Ethon
6
+ class Easy
7
+
8
+ # This class represents a form and is used to send a payload in the
9
+ # request body via POST/PUT.
10
+ # It handles multipart forms, too.
11
+ #
12
+ # @api private
13
+ class Form
14
+ include Ethon::Easy::Util
15
+ include Ethon::Easy::Queryable
16
+
17
+ # Return a new Form.
18
+ #
19
+ # @example Return a new Form.
20
+ # Form.new({})
21
+ #
22
+ # @param [ Hash ] params The parameter with which to initialize the form.
23
+ #
24
+ # @return [ Form ] A new Form.
25
+ def initialize(easy, params, multipart = nil)
26
+ @easy = easy
27
+ @params = params || {}
28
+ @multipart = multipart
29
+ end
30
+
31
+ # Return a pointer to the first form element in libcurl.
32
+ #
33
+ # @example Return the first form element.
34
+ # form.first
35
+ #
36
+ # @return [ FFI::Pointer ] The first element.
37
+ def first
38
+ @first ||= FFI::MemoryPointer.new(:pointer)
39
+ end
40
+
41
+ # Return a pointer to the last form element in libcurl.
42
+ #
43
+ # @example Return the last form element.
44
+ # form.last
45
+ #
46
+ # @return [ FFI::Pointer ] The last element.
47
+ def last
48
+ @last ||= FFI::MemoryPointer.new(:pointer)
49
+ end
50
+
51
+ # Return if form is multipart. The form is multipart when the multipart
52
+ # option is set, when it contains a file, or when a value is wrapped in a
53
+ # Multipart::Part that carries a content type or a filename. A wrapped
54
+ # plain value is encoded like an unwrapped one.
55
+ #
56
+ # @example Return if form is multipart.
57
+ # form.multipart?
58
+ #
59
+ # @return [ Boolean ] True if form is multipart, else false.
60
+ def multipart?
61
+ return true if @multipart
62
+ contains_multipart_part?(@params)
63
+ end
64
+
65
+ # Add form elements to libcurl.
66
+ #
67
+ # @example Add form to libcurl.
68
+ # form.materialize
69
+ def materialize
70
+ unless Curl.respond_to?(:formadd)
71
+ raise NotImplementedError,
72
+ "curl_formadd is not supported by this libcurl; use the MIME API instead"
73
+ end
74
+
75
+ ensure_named_fields!
76
+ query_pairs.each { |pair| form_add(pair.first.to_s, pair.last) }
77
+ end
78
+
79
+ # Build a MIME structure for this form.
80
+ #
81
+ # @example Build a MIME structure.
82
+ # form.mime
83
+ #
84
+ # @return [ Ethon::Curl::Mime ] The MIME structure.
85
+ def mime
86
+ @mime ||= begin
87
+ ensure_named_fields!
88
+ structure = Ethon::Curl::Mime.new(@easy)
89
+ query_pairs.each do |pair|
90
+ part = structure.addpart
91
+ name, content = pair
92
+ part.name = name.to_s
93
+ add_mime_part(part, content)
94
+ end
95
+ structure
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ # A multipart part needs a field name. A raw String body is one pair and
102
+ # has no name, which used to produce an unnamed part through the MIME API
103
+ # and a NoMethodError through the form API.
104
+ def ensure_named_fields!
105
+ return unless query_pairs.any? { |pair| pair.is_a?(String) }
106
+
107
+ raise ArgumentError, "multipart bodies require a Hash of fields"
108
+ end
109
+
110
+ def contains_multipart_part?(value)
111
+ case value
112
+ when Multipart::Part
113
+ value.upload? || !value.content_type.nil?
114
+ when Hash
115
+ value.values.any? { |item| contains_multipart_part?(item) }
116
+ when Array
117
+ value.any? { |item| contains_multipart_part?(item) }
118
+ else
119
+ Multipart::Part.file?(value)
120
+ end
121
+ end
122
+
123
+ def add_mime_part(part, content)
124
+ case content
125
+ when Multipart::Part
126
+ add_mime_part_from_part(part, content)
127
+ when Queryable::FileInfo
128
+ part.file = content[2]
129
+ part.filename = content[0]
130
+ part.type = content[1]
131
+ else
132
+ part.data = content.to_s
133
+ end
134
+ end
135
+
136
+ def add_mime_part_from_part(part, content)
137
+ unless content.upload?
138
+ part.data = content.value.to_s
139
+ part.type = content.content_type unless content.content_type.nil?
140
+ return
141
+ end
142
+
143
+ filename = part_filename(content)
144
+ content_type = part_content_type(content, filename)
145
+
146
+ if content.file?
147
+ part.file = part_path(content)
148
+ else
149
+ part.data = content.value.to_s
150
+ end
151
+ part.filename = filename
152
+ part.type = content_type
153
+ end
154
+
155
+ def form_add(name, content)
156
+ name = validate_header_line(:name, name.to_s)
157
+ options = [
158
+ :form_option, :copyname, :pointer, name,
159
+ :form_option, :namelength, :long, name.bytesize
160
+ ]
161
+
162
+ case content
163
+ when Multipart::Part
164
+ add_form_options_for_part(options, content)
165
+ when Queryable::FileInfo
166
+ add_form_file_options(options, content[2], content[0], content[1])
167
+ else
168
+ data = content.to_s
169
+ options.concat([
170
+ :form_option, :copycontents, :pointer, data,
171
+ :form_option, :contentslength, :long, data.bytesize
172
+ ])
173
+ end
174
+
175
+ options << :form_option << :end
176
+ code = Curl.formadd(first, last, *options)
177
+
178
+ raise Errors::FormAdd.new(code) unless code == 0
179
+
180
+ setup_garbage_collection
181
+ end
182
+
183
+ def add_form_options_for_part(options, content)
184
+ unless content.upload?
185
+ data = content.value.to_s
186
+ options.concat([
187
+ :form_option, :copycontents, :pointer, data,
188
+ :form_option, :contentslength, :long, data.bytesize
189
+ ])
190
+ return if content.content_type.nil?
191
+
192
+ content_type = validate_header_line(:content_type, content.content_type.to_s)
193
+ options.concat([:form_option, :contenttype, :string, content_type])
194
+ return
195
+ end
196
+
197
+ filename = part_filename(content)
198
+ content_type = part_content_type(content, filename)
199
+
200
+ if content.file?
201
+ add_form_file_options(options, part_path(content), filename, content_type)
202
+ else
203
+ add_form_buffer_options(options, content.value.to_s, filename, content_type)
204
+ end
205
+ end
206
+
207
+ # libcurl keeps the path and opens the file when the form is sent, so
208
+ # make it absolute in case the process changes directory in between.
209
+ def part_path(part)
210
+ File.expand_path(part.value.path)
211
+ end
212
+
213
+ def part_filename(part)
214
+ part.filename || File.basename(part.value.path)
215
+ end
216
+
217
+ def part_content_type(part, filename)
218
+ part.content_type || mime_type(filename)
219
+ end
220
+
221
+ def add_form_file_options(options, path, filename, content_type)
222
+ # The form API writes these into Content-Disposition headers. Older
223
+ # libcurl versions do not escape them.
224
+ filename = validate_header_line(:filename, filename.to_s)
225
+ content_type = validate_header_line(:content_type, content_type.to_s)
226
+ options.concat([
227
+ :form_option, :file, :string, path,
228
+ :form_option, :filename, :string, filename,
229
+ :form_option, :contenttype, :string, content_type
230
+ ])
231
+ end
232
+
233
+ def add_form_buffer_options(options, data, filename, content_type)
234
+ filename = validate_header_line(:filename, filename.to_s)
235
+ content_type = validate_header_line(:content_type, content_type.to_s)
236
+
237
+ # CURLFORM_BUFFERPTR does not copy the data, so keep a stable copy
238
+ # alive until libcurl has read the form during perform. The caller's
239
+ # String can be changed after setup, and the GC can move it.
240
+ buffer = FFI::MemoryPointer.from_string(data)
241
+ (@form_buffers ||= []) << buffer
242
+
243
+ options.concat([
244
+ :form_option, :buffer, :string, filename,
245
+ :form_option, :bufferptr, :pointer, buffer,
246
+ :form_option, :bufferlength, :long, data.bytesize,
247
+ :form_option, :contenttype, :string, content_type
248
+ ])
249
+ end
250
+
251
+ def setup_garbage_collection
252
+ # first is a pointer to a pointer. Since it's a MemoryPointer it will
253
+ # auto clean itself up, but we need to clean up the object it points
254
+ # to. So this results in (pseudo-c):
255
+ # form_data_cleanup_handler = *first
256
+ # curl_form_free(form_data_cleanup_handler)
257
+ @form_data_cleanup_handler ||= Curl::FormData.new(@first.get_pointer(0))
258
+ end
259
+ end
260
+ end
261
+ end
@@ -9,6 +9,19 @@ module Ethon
9
9
 
10
10
  # Holds available informations and their type, which is needed to
11
11
  # request the informations from libcurl.
12
+ #
13
+ # Everything listed here is read for every response that builds a
14
+ # Mirror, so it stays limited to values that are cheap, not deprecated,
15
+ # and not tied to a single protocol. Deliberately left out:
16
+ #
17
+ # * CURLINFO_PRIVATE returns the pointer set with CURLOPT_PRIVATE, not a
18
+ # C string, so a string getter would read freed memory.
19
+ # * CURLINFO_FILETIME, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
20
+ # CURLINFO_CONTENT_LENGTH_UPLOAD and CURLINFO_LASTSOCKET are superseded
21
+ # by filetime_t, content_length_*_t and activesocket, which are listed
22
+ # above.
23
+ # * The RTSP informations and CURLINFO_FTP_ENTRY_PATH are only set for
24
+ # those protocols.
12
25
  AVAILABLE_INFORMATIONS = {
13
26
  # The _T variants use curl_off_t and do not lose precision for large
14
27
  # values or long-running transfers.
@@ -39,13 +52,24 @@ module Ethon
39
52
  :httpauth_used => :long,
40
53
  :proxyauth_used => :long,
41
54
  :proxy_ssl_verifyresult => :long,
55
+ # Result of the SSL peer certificate verification. Zero means the
56
+ # certificate was verified successfully. (Added in 7.19.0)
57
+ :ssl_verifyresult => :long,
42
58
  :proxy_error => :long,
43
59
  :used_proxy => :long,
60
+ :local_port => :long,
61
+ :num_connects => :long,
62
+ :os_errno => :long,
63
+ :http_connectcode => :long,
64
+ :proxyauth_avail => :long,
65
+ :condition_unmet => :long,
66
+ :header_size => :long,
44
67
  :scheme => :string,
45
68
  :effective_method => :string,
46
69
  :referer => :string,
47
70
  :cainfo => :string,
48
71
  :capath => :string,
72
+ :content_type => :string,
49
73
  :activesocket => :socket,
50
74
  :tls_ssl_ptr => :ptr,
51
75
 
@@ -100,6 +124,12 @@ module Ethon
100
124
  # may be IPv6 if that's enabled.
101
125
  :primary_ip => :string,
102
126
 
127
+ # Return the local IP address of the most recent connection.
128
+ :local_ip => :string,
129
+
130
+ # Return the destination port of the most recent connection.
131
+ :primary_port => :long,
132
+
103
133
  # Return the last received HTTP, FTP or SMTP response code.
104
134
  # The value will be zero if no server response code has
105
135
  # been received. Note that a proxy's CONNECT response should
@@ -8,9 +8,15 @@ module Ethon
8
8
  # Raw pointers cannot be marshaled and point into native state that can
9
9
  # go away when the handle is reset. Applications serialize a mirror (for
10
10
  # example as a cached Typhoeus response), so leave them on the Easy.
11
+ #
12
+ # certinfo is appended by hand because libcurl returns a list of lists
13
+ # for it rather than a scalar, so it is not part of
14
+ # AVAILABLE_INFORMATIONS. It is read on every mirror like the rest,
15
+ # which costs one getinfo call that returns NULL when the Easy was not
16
+ # asked for the chain.
11
17
  INFORMATIONS_TO_MIRROR = Informations::AVAILABLE_INFORMATIONS.
12
18
  reject { |_, type| type == :ptr }.keys +
13
- [:return_code, :response_headers, :response_body, :debug_info, :error_message]
19
+ [:return_code, :response_headers, :response_body, :debug_info, :error_message, :certinfo]
14
20
 
15
21
  INFORMATIONS_TO_LOG = [:effective_url, :response_code, :return_code, :total_time]
16
22
 
@@ -219,9 +219,12 @@ module Ethon
219
219
  @postfields = nil
220
220
  @postfields_pointer = nil
221
221
  @postfield_body_size = nil
222
- # -1 is libcurl's default: the body ends at the first NUL.
223
- Curl.set_option(:postfieldsize, -1, handle)
224
- @postfieldsize_value = -1
222
+ # A zero size keeps libcurl on the null reader, which sends
223
+ # Content-Length: 0. With the size left at -1 libcurl treats the
224
+ # body as indeterminate, sends it chunked, and reads it from the
225
+ # default read callback, which is stdin.
226
+ Curl.set_option(:postfieldsize, 0, handle)
227
+ @postfieldsize_value = nil
225
228
  else
226
229
  string = value.to_s
227
230
  string = string.dup.freeze unless string.frozen?
@@ -249,10 +252,11 @@ module Ethon
249
252
  @postfields = nil
250
253
  @postfields_pointer = nil
251
254
  @postfield_body_size = nil
252
- # Clear the size too: libcurl fails the request when a non-zero size
253
- # is paired with the NULL body left by COPYPOSTFIELDS.
254
- Curl.set_option(:postfieldsize, -1, handle)
255
- @postfieldsize_value = -1
255
+ # Clear the size too, otherwise libcurl keeps describing the copy
256
+ # that is being removed. Zero rather than -1 for the same reason as
257
+ # in #postfields=.
258
+ Curl.set_option(:postfieldsize, 0, handle)
259
+ @postfieldsize_value = nil
256
260
  return value
257
261
  end
258
262
 
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'ethon/multipart'
3
+
2
4
  module Ethon
3
5
  class Easy
4
6
 
@@ -186,6 +188,9 @@ module Ethon
186
188
 
187
189
  def pairs_for(v, key, pairs)
188
190
  case v
191
+ when Multipart::Part
192
+ # The form builders need the metadata, so keep the part intact.
193
+ pairs << [key, v]
189
194
  when Hash, Array
190
195
  recursively_generate_pairs(v, key, pairs)
191
196
  when File, Tempfile
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module Ethon
3
+ module Errors
4
+ class ForkSafety < EthonError
5
+ def initialize(message = "Ethon cannot use libcurl initialized before a fork; use fork+exec or initialize libcurl after forking")
6
+ super(message)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -15,6 +15,11 @@ module Ethon
15
15
  Gem.win_platform?
16
16
  end
17
17
 
18
+ # :nodoc:
19
+ def self.macos?
20
+ FFI::Platform.mac?
21
+ end
22
+
18
23
  def self.open_max
19
24
  value = Etc.sysconf(Etc::SC_OPEN_MAX)
20
25
  return value if value && value > 0
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ethon
4
+ # Multipart form data support.
5
+ module Multipart
6
+ # A single part of a multipart form body.
7
+ #
8
+ # Wrap a value to control the content type, and optionally the filename,
9
+ # that Ethon sends for that field. Values that are not wrapped keep the
10
+ # existing behaviour: files are detected with mime-types and plain values
11
+ # have no content type.
12
+ #
13
+ # @example A JSON field.
14
+ # Ethon::Multipart::Part.new('{"a":1}', content_type: "application/json")
15
+ #
16
+ # @example A file with an explicit filename and content type.
17
+ # Ethon::Multipart::Part.new(
18
+ # File.open("photo.jpg"),
19
+ # filename: "avatar.png",
20
+ # content_type: "image/png"
21
+ # )
22
+ #
23
+ # @example An in-memory upload.
24
+ # Ethon::Multipart::Part.new(
25
+ # "file contents",
26
+ # filename: "notes.txt",
27
+ # content_type: "text/plain"
28
+ # )
29
+ class Part
30
+ # @return [ String, File, Tempfile ] The value sent for this field.
31
+ attr_reader :value
32
+
33
+ # @return [ String, nil ] The filename sent for an upload.
34
+ attr_reader :filename
35
+
36
+ # @return [ String, nil ] The content type sent for this part.
37
+ attr_reader :content_type
38
+
39
+ # Create a new multipart part.
40
+ #
41
+ # A value that responds to #read must be a File or Tempfile. Ethon
42
+ # sends files by path; other IO objects have to be read by the caller.
43
+ #
44
+ # @param [ String, File, Tempfile ] value The value of the part.
45
+ # @param [ String, nil ] filename The filename to send. Setting it turns
46
+ # a String value into a file part.
47
+ # @param [ String, nil ] content_type The content type for this part.
48
+ #
49
+ # @raise [ ArgumentError ] If value is an IO that Ethon cannot upload.
50
+ def initialize(value, filename: nil, content_type: nil)
51
+ if value.respond_to?(:read) && !self.class.file?(value)
52
+ raise ArgumentError,
53
+ "multipart parts take a String or a File, not #{value.class}; read the IO first"
54
+ end
55
+
56
+ @value = value
57
+ @filename = filename
58
+ @content_type = content_type
59
+ end
60
+
61
+ # Return whether the value is a file Ethon can read by path.
62
+ #
63
+ # @return [ Boolean ] True for File and Tempfile values.
64
+ def file?
65
+ self.class.file?(value)
66
+ end
67
+
68
+ # Return whether this part is an upload rather than a regular field.
69
+ # A filename turns in-memory data into an upload, matching curl's
70
+ # "-F name=value;filename=..." behaviour.
71
+ #
72
+ # @return [ Boolean ] True when the part has a file or a filename.
73
+ def upload?
74
+ file? || !filename.nil?
75
+ end
76
+
77
+ # @api private
78
+ def self.file?(value)
79
+ value.is_a?(File) || (defined?(Tempfile) && value.is_a?(Tempfile))
80
+ end
81
+
82
+ # Return the value as a string, so a part can still be encoded like a
83
+ # plain form value when a caller asks for a non-multipart body.
84
+ #
85
+ # @return [ String ] The string representation of the value.
86
+ def to_s
87
+ value.to_s
88
+ end
89
+
90
+ def ==(other)
91
+ other.is_a?(Part) &&
92
+ value_key == other.value_key &&
93
+ filename == other.filename &&
94
+ content_type == other.content_type
95
+ end
96
+ alias eql? ==
97
+
98
+ def hash
99
+ [Part, value_key, filename, content_type].hash
100
+ end
101
+
102
+ # The value used by #== and #hash. Files compare by path because File
103
+ # itself compares by identity.
104
+ #
105
+ # @api private
106
+ def value_key
107
+ file? ? value.path : value
108
+ end
109
+
110
+ def inspect
111
+ "#<#{self.class} value=#{value.inspect} filename=#{filename.inspect} content_type=#{content_type.inspect}>"
112
+ end
113
+ end
114
+ end
115
+ end
@@ -2,5 +2,5 @@
2
2
  module Ethon
3
3
 
4
4
  # Ethon version.
5
- VERSION = '0.19.1'
5
+ VERSION = '0.19.2'
6
6
  end
@@ -7,6 +7,7 @@ require 'tempfile'
7
7
  require 'ethon/libc'
8
8
  require 'ethon/curl'
9
9
  require 'ethon/curls/mime'
10
+ require 'ethon/multipart'
10
11
  require 'ethon/easy'
11
12
  require 'ethon/easy/url'
12
13
  require 'ethon/easy/mime'
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ethon 0.19.1 ruby lib
2
+ # stub: ethon 0.19.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ethon".freeze
6
- s.version = "0.19.1"
6
+ s.version = "0.19.2"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
- s.metadata = { "bug_tracker_uri" => "https://github.com/typhoeus/ethon/issues", "changelog_uri" => "https://github.com/typhoeus/ethon/blob/v0.19.1/CHANGELOG.md", "documentation_uri" => "https://www.rubydoc.info/gems/ethon/0.19.1", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/typhoeus/ethon/tree/v0.19.1" } if s.respond_to? :metadata=
9
+ s.metadata = { "bug_tracker_uri" => "https://github.com/typhoeus/ethon/issues", "changelog_uri" => "https://github.com/typhoeus/ethon/blob/v0.19.2/CHANGELOG.md", "documentation_uri" => "https://www.rubydoc.info/gems/ethon/0.19.2", "rubygems_mfa_required" => "true", "source_code_uri" => "https://github.com/typhoeus/ethon/tree/v0.19.2" } if s.respond_to? :metadata=
10
10
  s.require_paths = ["lib".freeze]
11
11
  s.authors = ["Hans Hasselberg".freeze]
12
- s.date = "2026-10-28"
12
+ s.date = "2026-11-12"
13
13
  s.description = "Very lightweight libcurl wrapper.".freeze
14
14
  s.email = ["me@hans.io".freeze]
15
15
  s.homepage = "https://github.com/typhoeus/ethon".freeze