tungo-sdk 0.2.0 → 0.3.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.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +64 -1
  3. data/README.md +6 -6
  4. data/lib/tungo/client.rb +16 -8
  5. data/lib/tungo/helpers.rb +3 -1
  6. data/lib/tungo/internal/sse.rb +91 -0
  7. data/lib/tungo/internal/util.rb +31 -0
  8. data/lib/tungo/models/api_key.rb +9 -1
  9. data/lib/tungo/models/api_key_create.rb +9 -2
  10. data/lib/tungo/models/api_key_created.rb +9 -1
  11. data/lib/tungo/models/api_key_details.rb +9 -1
  12. data/lib/tungo/models/api_key_patch.rb +7 -0
  13. data/lib/tungo/models/api_key_rolled.rb +19 -4
  14. data/lib/tungo/models/api_key_self.rb +9 -1
  15. data/lib/tungo/models/api_key_updated.rb +9 -1
  16. data/lib/tungo/models/api_key_usage_by_model_item.rb +1 -1
  17. data/lib/tungo/models/audit_entry.rb +16 -6
  18. data/lib/tungo/models/audit_entry_action.rb +70 -3
  19. data/lib/tungo/models/audit_entry_object.rb +43 -0
  20. data/lib/tungo/models/audit_entry_object_purpose.rb +25 -0
  21. data/lib/tungo/models/batch_statement.rb +38 -0
  22. data/lib/tungo/models/batch_statement_account.rb +50 -0
  23. data/lib/tungo/models/batch_summary.rb +6 -0
  24. data/lib/tungo/models/card_session.rb +6 -0
  25. data/lib/tungo/models/card_session_state.rb +28 -0
  26. data/lib/tungo/models/card_session_state_failure_code.rb +20 -0
  27. data/lib/tungo/models/card_session_state_status.rb +19 -0
  28. data/lib/tungo/models/chat_assistant_message.rb +22 -0
  29. data/lib/tungo/models/chat_choice_answer.rb +9 -1
  30. data/lib/tungo/models/chat_choice_question.rb +9 -1
  31. data/lib/tungo/models/chat_citation.rb +62 -5
  32. data/lib/tungo/models/chat_dialog.rb +17 -1
  33. data/lib/tungo/models/chat_dialog_patch.rb +2 -1
  34. data/lib/tungo/models/chat_dialog_rated.rb +25 -0
  35. data/lib/tungo/models/chat_dialog_rating.rb +25 -0
  36. data/lib/tungo/models/chat_dialog_rating_body.rb +21 -0
  37. data/lib/tungo/models/chat_dialog_renamed.rb +4 -0
  38. data/lib/tungo/models/chat_dialog_summary.rb +6 -2
  39. data/lib/tungo/models/chat_event.rb +6 -2
  40. data/lib/tungo/models/chat_event_citation.rb +54 -5
  41. data/lib/tungo/models/chat_event_done.rb +8 -1
  42. data/lib/tungo/models/chat_event_next.rb +27 -0
  43. data/lib/tungo/models/chat_event_title.rb +22 -0
  44. data/lib/tungo/models/chat_history_batch.rb +21 -0
  45. data/lib/tungo/models/chat_history_block.rb +3 -1
  46. data/lib/tungo/models/chat_history_error.rb +3 -3
  47. data/lib/tungo/models/chat_history_error_code.rb +4 -3
  48. data/lib/tungo/models/chat_history_mention.rb +29 -0
  49. data/lib/tungo/models/chat_history_mention_type.rb +20 -0
  50. data/lib/tungo/models/chat_history_question.rb +6 -1
  51. data/lib/tungo/models/chat_history_question_answer.rb +31 -0
  52. data/lib/tungo/models/chat_history_question_answer_via.rb +17 -0
  53. data/lib/tungo/models/chat_mention.rb +22 -0
  54. data/lib/tungo/models/chat_mention_item.rb +33 -0
  55. data/lib/tungo/models/chat_mention_item_type.rb +20 -0
  56. data/lib/tungo/models/chat_mention_search.rb +21 -0
  57. data/lib/tungo/models/chat_mention_type.rb +20 -0
  58. data/lib/tungo/models/chat_mention_unavailable.rb +23 -0
  59. data/lib/tungo/models/chat_mention_unavailable_reason.rb +19 -0
  60. data/lib/tungo/models/chat_mention_unavailable_type.rb +20 -0
  61. data/lib/tungo/models/chat_message_rated.rb +31 -0
  62. data/lib/tungo/models/chat_message_rating.rb +30 -0
  63. data/lib/tungo/models/chat_message_rating_body.rb +27 -0
  64. data/lib/tungo/models/chat_message_rating_body_vote.rb +17 -0
  65. data/lib/tungo/models/chat_message_rating_vote.rb +17 -0
  66. data/lib/tungo/models/chat_message_request.rb +14 -0
  67. data/lib/tungo/models/chat_message_request_effort.rb +22 -0
  68. data/lib/tungo/models/chat_next_action.rb +31 -0
  69. data/lib/tungo/models/chat_next_action_code.rb +21 -0
  70. data/lib/tungo/models/chat_next_action_params_value.rb +20 -0
  71. data/lib/tungo/models/chat_rating_dismissed.rb +21 -0
  72. data/lib/tungo/models/chat_rating_options.rb +25 -0
  73. data/lib/tungo/models/chat_rating_options_dialog_scores.rb +20 -0
  74. data/lib/tungo/models/chat_rating_options_reason_item.rb +20 -0
  75. data/lib/tungo/models/chat_suggestion.rb +41 -0
  76. data/lib/tungo/models/chat_suggestion_action.rb +17 -0
  77. data/lib/tungo/models/chat_suggestion_group.rb +26 -0
  78. data/lib/tungo/models/chat_suggestions.rb +25 -0
  79. data/lib/tungo/models/chat_suggestions_locale.rb +17 -0
  80. data/lib/tungo/models/chat_title_source.rb +20 -0
  81. data/lib/tungo/models/chat_turn_error.rb +9 -5
  82. data/lib/tungo/models/chat_turn_error_code.rb +4 -3
  83. data/lib/tungo/models/chat_turn_error_limit_kind.rb +7 -1
  84. data/lib/tungo/models/chat_turn_result.rb +11 -0
  85. data/lib/tungo/models/chat_user_message.rb +5 -0
  86. data/lib/tungo/models/company.rb +2 -2
  87. data/lib/tungo/models/company_legal_form.rb +2 -1
  88. data/lib/tungo/models/company_list_item.rb +2 -2
  89. data/lib/tungo/models/error_detail.rb +32 -2
  90. data/lib/tungo/models/error_detail_free_blocked_reason.rb +25 -0
  91. data/lib/tungo/models/get_workspace_platform_audit_response.rb +11 -0
  92. data/lib/tungo/models/list_company_chat_rating_options_lang.rb +17 -0
  93. data/lib/tungo/models/list_company_chat_suggestions_lang.rb +18 -0
  94. data/lib/tungo/models/list_company_proposals_approval_requested.rb +17 -0
  95. data/lib/tungo/models/list_workspace_platform_requests_response.rb +11 -0
  96. data/lib/tungo/models/pay_form.rb +6 -0
  97. data/lib/tungo/models/platform_account_purchase_limits.rb +6 -0
  98. data/lib/tungo/models/platform_ledger_entry.rb +7 -0
  99. data/lib/tungo/models/platform_ledger_entry_documents.rb +33 -0
  100. data/lib/tungo/models/platform_ledger_entry_documents_receipt_status.rb +20 -0
  101. data/lib/tungo/models/platform_request.rb +7 -0
  102. data/lib/tungo/models/proposal_approval_request.rb +27 -0
  103. data/lib/tungo/models/proposal_approval_request_body.rb +15 -0
  104. data/lib/tungo/models/proposal_approval_request_result.rb +31 -0
  105. data/lib/tungo/models/proposal_approval_requested.rb +32 -0
  106. data/lib/tungo/models/proposal_card.rb +16 -1
  107. data/lib/tungo/models/proposal_card_status_reason.rb +23 -0
  108. data/lib/tungo/models/proposal_history_event.rb +7 -0
  109. data/lib/tungo/models/proposal_list_item.rb +16 -1
  110. data/lib/tungo/models/proposal_list_item_status_reason.rb +23 -0
  111. data/lib/tungo/models/proposal_origin.rb +33 -0
  112. data/lib/tungo/models/proposal_origin_source.rb +21 -0
  113. data/lib/tungo/models/proposal_page.rb +9 -2
  114. data/lib/tungo/models/usage_rate.rb +15 -2
  115. data/lib/tungo/models.rb +58 -0
  116. data/lib/tungo/money.rb +14 -1
  117. data/lib/tungo/request_options.rb +3 -1
  118. data/lib/tungo/resources/automations.rb +6 -3
  119. data/lib/tungo/resources/chat.rb +175 -2
  120. data/lib/tungo/resources/proposals.rb +49 -2
  121. data/lib/tungo/transport.rb +9 -1
  122. data/lib/tungo/version.rb +1 -1
  123. data/sig/tungo/models/api_key.rbs +2 -1
  124. data/sig/tungo/models/api_key_create.rbs +3 -2
  125. data/sig/tungo/models/api_key_created.rbs +2 -1
  126. data/sig/tungo/models/api_key_details.rbs +2 -1
  127. data/sig/tungo/models/api_key_patch.rbs +2 -1
  128. data/sig/tungo/models/api_key_rolled.rbs +4 -2
  129. data/sig/tungo/models/api_key_self.rbs +2 -1
  130. data/sig/tungo/models/api_key_updated.rbs +2 -1
  131. data/sig/tungo/models/audit_entry.rbs +2 -1
  132. data/sig/tungo/models/audit_entry_action.rbs +67 -0
  133. data/sig/tungo/models/audit_entry_object.rbs +16 -0
  134. data/sig/tungo/models/audit_entry_object_purpose.rbs +19 -0
  135. data/sig/tungo/models/batch_statement.rbs +16 -0
  136. data/sig/tungo/models/batch_statement_account.rbs +19 -0
  137. data/sig/tungo/models/batch_summary.rbs +2 -1
  138. data/sig/tungo/models/card_session.rbs +2 -1
  139. data/sig/tungo/models/card_session_state.rbs +14 -0
  140. data/sig/tungo/models/card_session_state_failure_code.rbs +14 -0
  141. data/sig/tungo/models/card_session_state_status.rbs +14 -0
  142. data/sig/tungo/models/chat_assistant_message.rbs +5 -1
  143. data/sig/tungo/models/chat_choice_answer.rbs +2 -1
  144. data/sig/tungo/models/chat_choice_question.rbs +2 -1
  145. data/sig/tungo/models/chat_citation.rbs +11 -1
  146. data/sig/tungo/models/chat_dialog.rbs +4 -1
  147. data/sig/tungo/models/chat_dialog_rated.rbs +14 -0
  148. data/sig/tungo/models/chat_dialog_rating.rbs +14 -0
  149. data/sig/tungo/models/chat_dialog_rating_body.rbs +13 -0
  150. data/sig/tungo/models/chat_dialog_renamed.rbs +2 -1
  151. data/sig/tungo/models/chat_dialog_summary.rbs +2 -1
  152. data/sig/tungo/models/chat_event.rbs +1 -1
  153. data/sig/tungo/models/chat_event_citation.rbs +10 -1
  154. data/sig/tungo/models/chat_event_done.rbs +2 -1
  155. data/sig/tungo/models/chat_event_next.rbs +14 -0
  156. data/sig/tungo/models/chat_event_title.rbs +13 -0
  157. data/sig/tungo/models/chat_history_batch.rbs +13 -0
  158. data/sig/tungo/models/chat_history_block.rbs +1 -1
  159. data/sig/tungo/models/chat_history_error_code.rbs +1 -0
  160. data/sig/tungo/models/chat_history_mention.rbs +14 -0
  161. data/sig/tungo/models/chat_history_mention_type.rbs +14 -0
  162. data/sig/tungo/models/chat_history_question.rbs +2 -1
  163. data/sig/tungo/models/chat_history_question_answer.rbs +15 -0
  164. data/sig/tungo/models/chat_history_question_answer_via.rbs +13 -0
  165. data/sig/tungo/models/chat_mention.rbs +13 -0
  166. data/sig/tungo/models/chat_mention_item.rbs +15 -0
  167. data/sig/tungo/models/chat_mention_item_type.rbs +14 -0
  168. data/sig/tungo/models/chat_mention_search.rbs +13 -0
  169. data/sig/tungo/models/chat_mention_type.rbs +14 -0
  170. data/sig/tungo/models/chat_mention_unavailable.rbs +13 -0
  171. data/sig/tungo/models/chat_mention_unavailable_reason.rbs +14 -0
  172. data/sig/tungo/models/chat_mention_unavailable_type.rbs +14 -0
  173. data/sig/tungo/models/chat_message_rated.rbs +15 -0
  174. data/sig/tungo/models/chat_message_rating.rbs +15 -0
  175. data/sig/tungo/models/chat_message_rating_body.rbs +14 -0
  176. data/sig/tungo/models/chat_message_rating_body_vote.rbs +13 -0
  177. data/sig/tungo/models/chat_message_rating_vote.rbs +13 -0
  178. data/sig/tungo/models/chat_message_request.rbs +3 -1
  179. data/sig/tungo/models/chat_message_request_effort.rbs +16 -0
  180. data/sig/tungo/models/chat_next_action.rbs +14 -0
  181. data/sig/tungo/models/chat_next_action_code.rbs +15 -0
  182. data/sig/tungo/models/chat_next_action_params_value.rbs +12 -0
  183. data/sig/tungo/models/chat_rating_dismissed.rbs +13 -0
  184. data/sig/tungo/models/chat_rating_options.rbs +14 -0
  185. data/sig/tungo/models/chat_rating_options_dialog_scores.rbs +13 -0
  186. data/sig/tungo/models/chat_rating_options_reason_item.rbs +13 -0
  187. data/sig/tungo/models/chat_suggestion.rbs +17 -0
  188. data/sig/tungo/models/chat_suggestion_action.rbs +13 -0
  189. data/sig/tungo/models/chat_suggestion_group.rbs +14 -0
  190. data/sig/tungo/models/chat_suggestions.rbs +14 -0
  191. data/sig/tungo/models/chat_suggestions_locale.rbs +13 -0
  192. data/sig/tungo/models/chat_title_source.rbs +14 -0
  193. data/sig/tungo/models/chat_turn_error_code.rbs +1 -0
  194. data/sig/tungo/models/chat_turn_error_limit_kind.rbs +4 -0
  195. data/sig/tungo/models/chat_turn_result.rbs +3 -1
  196. data/sig/tungo/models/chat_user_message.rbs +2 -1
  197. data/sig/tungo/models/company.rbs +2 -2
  198. data/sig/tungo/models/company_list_item.rbs +2 -2
  199. data/sig/tungo/models/error_detail.rbs +6 -1
  200. data/sig/tungo/models/error_detail_free_blocked_reason.rbs +19 -0
  201. data/sig/tungo/models/get_workspace_platform_audit_response.rbs +3 -1
  202. data/sig/tungo/models/list_company_chat_rating_options_lang.rbs +13 -0
  203. data/sig/tungo/models/list_company_chat_suggestions_lang.rbs +13 -0
  204. data/sig/tungo/models/list_company_proposals_approval_requested.rbs +13 -0
  205. data/sig/tungo/models/list_workspace_platform_requests_response.rbs +3 -1
  206. data/sig/tungo/models/pay_form.rbs +2 -1
  207. data/sig/tungo/models/platform_account_purchase_limits.rbs +2 -1
  208. data/sig/tungo/models/platform_ledger_entry.rbs +2 -1
  209. data/sig/tungo/models/platform_ledger_entry_documents.rbs +15 -0
  210. data/sig/tungo/models/platform_ledger_entry_documents_receipt_status.rbs +15 -0
  211. data/sig/tungo/models/platform_request.rbs +2 -1
  212. data/sig/tungo/models/proposal_approval_request.rbs +14 -0
  213. data/sig/tungo/models/proposal_approval_request_body.rbs +12 -0
  214. data/sig/tungo/models/proposal_approval_request_result.rbs +15 -0
  215. data/sig/tungo/models/proposal_approval_requested.rbs +15 -0
  216. data/sig/tungo/models/proposal_card.rbs +4 -1
  217. data/sig/tungo/models/proposal_card_status_reason.rbs +13 -0
  218. data/sig/tungo/models/proposal_history_event.rbs +2 -1
  219. data/sig/tungo/models/proposal_list_item.rbs +4 -1
  220. data/sig/tungo/models/proposal_list_item_status_reason.rbs +13 -0
  221. data/sig/tungo/models/proposal_origin.rbs +15 -0
  222. data/sig/tungo/models/proposal_origin_source.rbs +15 -0
  223. data/sig/tungo/models/proposal_page.rbs +2 -1
  224. data/sig/tungo/models/usage_rate.rbs +3 -1
  225. data/sig/tungo/resources/automations.rbs +1 -1
  226. data/sig/tungo/resources/chat.rbs +9 -2
  227. data/sig/tungo/resources/proposals.rbs +3 -2
  228. metadata +117 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c415a9a9702c830f7036d0f2331956c57bfcfb84e75e55069491d26433335903
4
- data.tar.gz: 32dee197f111c665c358d3a4420282e997cff09c1591a204dfc59e9cb5b71526
3
+ metadata.gz: 55972d32edd76c729727b7975a63ac868500e77fb8608416fe9bcf7e8b73a07c
4
+ data.tar.gz: d5285611cd54598addcc3a98e30ae1f205e362dd5207f9a72acf744799287809
5
5
  SHA512:
6
- metadata.gz: e6ca9fc4de6f8069f52c786140699f17af038928276c8fd07f099b44e37a7ac2efa5268e9f572f4b61d1dab7093a9cd68bd66d6036383b3917fd67a54b39bfb7
7
- data.tar.gz: d6be717d231df82023c2b2117b512806e18522db02424b2efa5522814ddbae60e0557fb3b4bd84c19f14a15f4733d1dcc698513093f1f64a91c170daffb4a687
6
+ metadata.gz: 6fbd1b4d73a812c3456101e82a2d7dda05d8d3f5da0234eba0cbbd3d4271db3a89c2a442fbc0aa053a102e479795efefe06e738c6ebee17c49e91e1f6053fa21
7
+ data.tar.gz: 2928b8f5bd1cdcc4ec8ae0524486ce712b0f9cfe20e0cd2b749233a363f5ef06c14859696b62895753c918d82ff70a863f1a43dcfe8f2f99b44e10bd6e44ae01
data/CHANGELOG.md CHANGED
@@ -9,6 +9,67 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.3.1] - 2026-11-13
13
+
14
+ 0.3.0 of this SDK was never published: its release build failed. 0.3.1 has the same content as 0.3.0 plus the build fix below; the changes since 0.2.0 are listed under 0.3.0.
15
+
16
+ ### Changed
17
+
18
+ - Release build: a code comment no longer names `CGI`, which the packaging test forbids in library sources. No change in behaviour.
19
+ - Release build: RuboCop offences fixed; the hook-signing and body idempotency key helpers moved from `Tungo::Client` to `Tungo::Internal::Util` (private API). No change in behaviour.
20
+
21
+ ## [0.3.0] - 2026-11-13
22
+
23
+ Generated from the platform contract of backend 44066d62. It contains breaking type changes compared with 0.2.0.
24
+
25
+ ### Breaking
26
+
27
+ - `Company.legal_form` and `CompanyListItem.legal_form` can be null: the legal form of a company is not set yet (it is set with `PATCH /v1/companies/{co}`). The field is now nullable or optional in every SDK (`CompanyLegalForm | null`, `Optional[CompanyLegalForm]`, `*CompanyLegalForm`, `Option<CompanyLegalForm>`, `Optional<CompanyLegalForm>`, `CompanyLegalForm?`).
28
+ - `ApiKeyRolled.key` is null when a key roll is replayed by `Idempotency-Key`; the new `key_note` says why and what to do if the new secret was lost. The field is now nullable in every SDK.
29
+ - `ApiKeyCreate.permissions` is optional (a key with `no_companies: true` gets no company permissions). Constructors and builders no longer require it (Rust: `ApiKeyCreate::new(name)`), accessors return an optional value, and Go leaves the field out for a nil list instead of sending `[]`.
30
+ - New union variants: `ChatEvent` gains `next` (`ChatEventNext`) and `title` (`ChatEventTitle`), `ChatHistoryBlock` gains `batch` (`ChatHistoryBatch`). An exhaustive `switch`/`when`/`match` over these unions needs the new cases.
31
+ - PHP and Kotlin: `proposals.list` and `listAll` gained the optional filters `approval_requested`, `batch_id` and `source` before existing parameters, so positional arguments after the company shift. Pass these parameters by name (PHP named arguments, Kotlin named arguments).
32
+ - An `Idempotency-Key` is sent only to operations that declare it: a caller's own `Idempotency-Key` on any other operation is no longer sent, and no longer makes a POST retryable. Approving a proposal uses the `idempotency_key` of the body as the header instead of generating one.
33
+ - Response models gained required fields (`no_companies` on the `ApiKey*` models; `title_source` on `ChatDialog`, `ChatDialogSummary` and `ChatDialogRenamed`; `followups` and `next_action` on `ChatAssistantMessage` and `ChatTurnResult`; `turn_no` and `rating` on `ChatAssistantMessage`; `rating` and `rating_prompt` on `ChatDialog`; `label` and `document` on `ChatCitation` and `ChatEventCitation`; `approval_request`, `origin` and `status_reason` on `ProposalCard` and `ProposalListItem`; `approval_requested_count` on `ProposalPage`; `object` on `AuditEntry`; `statement` on `BatchSummary`; `total` and `total_more` on the platform audit and request lists; and others). Decoding is unaffected; code that constructs these models itself (test fakes) must pass the new fields.
34
+
35
+ ### Added
36
+
37
+ - `chat.list_mentions` (`GET /v1/companies/{co}/chat/mentions`): finds proposals, batches and counterparties to mention in a question (`ChatMentionSearch`, `ChatMentionItem`, `ChatMentionUnavailable`). Questions take `mentions` (`ChatMention`), and history shows them (`ChatUserMessage.mentions`, `ChatHistoryMention`).
38
+ - `chat.list_suggestions` (`GET /v1/companies/{co}/chat/suggestions`, `lang` `ru` or `kk`): suggested questions grouped by topic (`ChatSuggestions`, `ChatSuggestionGroup`, `ChatSuggestion` with `code`, `action`, `title`, `hint`, `prompt` and `seasonal`).
39
+ - `proposals.request_approval` (`POST /v1/companies/{co}/proposals/{id}/request-approval`, optional `note`): asks the people who may approve a proposal to look at it (`ProposalApprovalRequestResult`). Proposals carry `approval_request` (`ProposalApprovalRequest`, `ProposalApprovalRequested`), `origin` (`ProposalOrigin`) and `status_reason`; `proposals.list` filters by `approval_requested`, `batch_id` and `source`; `ProposalHistoryEvent.code`.
40
+ - Chat: the dialog title has a `title_source` (`ChatTitleSource`: `first_message`, `ai`, `user`) and a `title` stream event (`ChatEventTitle`, sent to cabinet sessions only); a turn ends with suggested follow-ups and a next action (`followups`, `next_action`, `ChatNextAction`, event `next`); questions take `effort` (`low` to `max`); choice questions have `confirm`, answers `skipped`, and history shows the answer (`ChatHistoryQuestion.answer`); history shows batch jobs (`ChatHistoryBatch`).
41
+ - Chat ratings: `chat.rate_message` (`PUT /v1/companies/{co}/chat/{id}/messages/{turn}/rating`, `ChatMessageRatingBody` with `vote` `up` or `down`, optional `reason` and `comment`) rates one answer and `chat.delete_message_rating` (`DELETE` on the same path) removes that rating, both answering `ChatMessageRated`; `chat.rate` (`PUT /v1/companies/{co}/chat/{id}/rating`, `ChatDialogRatingBody` with `score` 1 to 5 and optional `comment`) rates the whole dialog (`ChatDialogRated`); `chat.dismiss_rating` (`POST /v1/companies/{co}/chat/{id}/rating/dismiss`) closes the offer to rate it (`ChatRatingDismissed`); `chat.get_rating_options` (`GET /v1/companies/{co}/chat/rating-options`, `lang` `ru` or `kk`) returns what a rating form needs (`ChatRatingOptions`: `reasons`, `comment_chars`, `dialog_scores`).
42
+ - Chat history: an assistant message has its `turn_no` (the `turn` of the rating methods) and its `rating` (`ChatMessageRating`); a dialog has its `rating` (`ChatDialogRating`) and `rating_prompt`, and the `done` stream event has an optional `rating_prompt` when it is time to offer rating the dialog (cabinet sessions only: with an API key it is always false or absent).
43
+ - Chat citations: `ChatCitation` and the `citation` stream event (`ChatEventCitation`) have a display `label` and the `document`, and optionally `article`, `point`, `subpoint`, `chapter`, `heading`, `edition_date` and `note` (a status mark such as a repealed norm, to be shown); `ChatCitation.mentions` lists how the answer text names the source, so those fragments can link to it.
44
+ - Errors: rating error codes `dialog_not_ratable`, `message_not_found`, `rating_reason_unknown`, `rating_reason_not_allowed`, `rating_comment_too_long` and `ratings_unavailable`.
45
+ - Batches: `BatchSummary.statement` describes a parsed bank statement by account (`BatchStatement`, `BatchStatementAccount`).
46
+ - Errors: `ErrorDetail` gains `free_blocked_reason`, `retry_after_seconds`, `next_request_at`, `amount_tiyn` and `payment_id`; chat turn errors gain the code `parallel_turns_limit` and limit kinds `disabled`, `meter`, `plan` and `turn`.
47
+ - API keys: `no_companies` on the API key models, on `ApiKeyCreate` and on `ApiKeyPatch`; `ApiKeyRolled.key_note`.
48
+ - Platform: `total` and `total_more` on the audit and request lists; `PlatformRequest.cost_tiyn`; `PlatformLedgerEntry.documents` (invoice, act and receipt); `PlatformAccountPurchaseLimits.today_tiyn`; `UsageRate.title` and `UsageRate.cache_write_1h_per_mtok_tiyn`; `AuditEntry.object` (`AuditEntryObject`) and new audit actions.
49
+ - Billing models used by the cabinet: `CardSessionState`, `CardSession.test_mode`, `PayForm.test_mode`.
50
+
51
+ ### Fixed
52
+
53
+ - A chat turn replayed by `Idempotency-Key`, including a stream call retried after a 502, arrives as its events; Python typed streams expose `last_event_id` for resuming.
54
+ - A replayed chat turn keeps its follow-ups and next action: when the stored result has `followups` or a `next_action`, the rebuilt stream yields the `next` event right before `done`, as a live turn does.
55
+ - An `error` event of the feed stream ends the stream with a typed error; Kotlin delivers the event that the end of a stream completes.
56
+ - Incoming hooks: the event id is the default `Idempotency-Key` (a caller's own header wins), and the signature goes into the hook's own `signature_header`.
57
+ - Webhook verification treats an infinite tolerance as `invalid_tolerance`.
58
+ - Money: the exponent of a decimal is bounded before it is converted to tiyn.
59
+ - Bad header values and base URLs fail locally without a request; transport and timeout errors no longer include the URL (Go, TypeScript); a decode error's debug output does not show the body (Rust).
60
+ - TypeScript: error paths serialise `bigint` safely and keep 64-bit extra fields exact; `debugJSON` returns `''` for a value JSON cannot express.
61
+ - Python: a `datetime` passed for a calendar-date parameter is sent as its date.
62
+ - Go: `UploadBankStatement` sends text that is not UTF-8 as the file instead of failing.
63
+ - Java: `close()` fails the asynchronous calls still waiting in the owned pool; `Retry-After` reads the RFC 850 date with a two-digit year; a key or header value with a control character is never quoted; error envelope fields are read in a way that works with Jackson 2.14, the documented minimum.
64
+ - PHP: `sendHook` reads the headers of optional request options null-safely.
65
+ - Ruby: the percent-encoded credentials of an explicit proxy are decoded.
66
+ - Swift: the `URLSession` of the SDK has no URL cache.
67
+ - .NET: a custom platform handler that follows redirects, or whose redirect setting cannot be read, is refused.
68
+
69
+ ### Known limitations
70
+
71
+ - Batch and proposal export downloads (xlsx, csv, pdf: `GET /v1/companies/{co}/batch/{id}/export` and `GET /v1/companies/{co}/proposals/{id}/export`) are not in this release: the SDKs cannot return a file body yet.
72
+
12
73
  ## [0.2.0] - 2026-11-12
13
74
 
14
75
  First production-ready release. It contains breaking changes compared with 0.1.0; 0.1.0 should not be used.
@@ -29,6 +90,8 @@ First production-ready release. It contains breaking changes compared with 0.1.0
29
90
 
30
91
  Initial preview. Not suitable for production use.
31
92
 
32
- [Unreleased]: https://github.com/TungoAI/tungo-sdk-ruby/compare/v0.2.0...HEAD
93
+ [Unreleased]: https://github.com/TungoAI/tungo-sdk-ruby/compare/v0.3.1...HEAD
94
+ [0.3.1]: https://github.com/TungoAI/tungo-sdk-ruby/compare/v0.3.0...v0.3.1
95
+ [0.3.0]: https://github.com/TungoAI/tungo-sdk-ruby/compare/v0.2.0...v0.3.0
33
96
  [0.2.0]: https://github.com/TungoAI/tungo-sdk-ruby/compare/v0.1.0...v0.2.0
34
97
  [0.1.0]: https://github.com/TungoAI/tungo-sdk-ruby/releases/tag/v0.1.0
data/README.md CHANGED
@@ -145,7 +145,7 @@ The class names are `Tungo::InvalidRequestError`, `AuthenticationError`, `Paymen
145
145
 
146
146
  ## Retries and timeouts
147
147
 
148
- A request is retried up to 2 times (3 attempts) on connection errors, timeouts and the statuses 408, 429, 500, 502, 503 and 504, but only when repeating it is safe: `GET`, `HEAD`, `PUT` and `DELETE` requests, and `POST` or `PATCH` requests that carry an `Idempotency-Key`. For the operations whose contract declares that header the SDK generates a random key and reuses it for every attempt; you can pass your own.
148
+ A request is retried up to 2 times (3 attempts) on connection errors, timeouts and the statuses 408, 429, 500, 502, 503 and 504, but only when repeating it is safe: `GET`, `HEAD`, `PUT` and `DELETE` requests, and `POST` or `PATCH` requests of the operations whose contract declares an `Idempotency-Key`. For those the SDK generates a random key and reuses it for every attempt; you can pass your own. Other operations send no key, not even one you pass, because the API would ignore it.
149
149
 
150
150
  The delay between attempts is `min(0.5 s × 2^attempt, 8 s)` with random jitter. A positive `retry-after-ms` or `Retry-After` response header overrides it; if the server asks for more than 60 s the SDK does not wait and raises the error with the delay filled in.
151
151
 
@@ -199,7 +199,7 @@ client.chat.create_stream(message: "Привет").each do |event|
199
199
  end
200
200
  ```
201
201
 
202
- All five streaming operations work the same way: `chat.create_stream`, `chat.answer_stream`, `chat.list_events`, `batches.list_events` (typed `ChatEvent` variants, as a `Tungo::ChatStream`) and `feed.list_events` (`FeedItem` objects). Heart-beats are skipped; `each_sse` yields the raw events instead. `accumulate` and `each_text` raise the typed `Tungo::APIError` if the turn reports an error, and `Tungo::DecodeError` ("stream ended before completion") if the stream ends with neither a `done` nor an `error` event, so a cut answer never looks like a finished turn; plain `each` simply ends. A success answer whose `Content-Type` is not `text/event-stream` raises `Tungo::DecodeError` when the stream is opened. A stream can be consumed once; it may be handed to another thread and read or closed there (each request runs on a worker thread of the transport), but not read by two threads at once. Pass `last_event_id:` to resume the pure event streams.
202
+ All five streaming operations work the same way: `chat.create_stream`, `chat.answer_stream`, `chat.list_events`, `batches.list_events` (typed `ChatEvent` variants, as a `Tungo::ChatStream`) and `feed.list_events` (`FeedItem` objects). Heart-beats are skipped; `each_sse` yields the raw events instead. `accumulate` and `each_text` raise the typed `Tungo::APIError` if the turn reports an error, and `Tungo::DecodeError` ("stream ended before completion") if the stream ends with neither a `done` nor an `error` event, so a cut answer never looks like a finished turn; plain `each` simply ends. A success answer whose `Content-Type` is not `text/event-stream` raises `Tungo::DecodeError` when the stream is opened. The exception is a finished chat turn that the API replays for a repeated `Idempotency-Key` (`application/json` with `Idempotent-Replayed: true`): its stored result arrives as the events of that turn, ending with `next` (follow-ups and the next action, when it has them) and `done`. A stream can be consumed once; it may be handed to another thread and read or closed there (each request runs on a worker thread of the transport), but not read by two threads at once. Pass `last_event_id:` to resume the pure event streams.
203
203
 
204
204
  ## Webhooks
205
205
 
@@ -270,7 +270,7 @@ The wait helpers poll with a pause that grows from 1 s to 5 s and raise `Tungo::
270
270
 
271
271
  ## API reference
272
272
 
273
- Generated from the Tungo Platform API contract: **13 resources, 82 methods, 22 webhook event types**.
273
+ Generated from the Tungo Platform API contract: **13 resources, 90 methods, 22 webhook event types**.
274
274
 
275
275
  | Resource | Description | Methods |
276
276
  | --- | --- | --- |
@@ -279,8 +279,8 @@ Generated from the Tungo Platform API contract: **13 resources, 82 methods, 22 w
279
279
  | `client.platform` | Platform balance, ledger, usage reports, limits, audit log and model rates | `list_usage_rates` · `get_account` · `get_audit / get_audit_all` · `get_ledger / get_ledger_all` · `list_limits` · `list_requests / list_requests_all` · `get_usage` |
280
280
  | `client.api_keys` | The current API key and its usage statistics | `get_current` · `get_current_usage` · `get_usage` |
281
281
  | `client.webhooks` | Outgoing webhooks of an organisation (Svix): endpoints, event catalogue, deliveries and signature check | `list_endpoints / list_endpoints_all` · `create_endpoint` · `get_endpoint` · `update_endpoint` · `delete_endpoint` · `list_endpoint_attempts / list_endpoint_attempts_all` · `rotate_endpoint_secret` · `test_endpoint` · `list_event_types` · `list_messages / list_messages_all` · `list_message_attempts / list_message_attempts_all` · `resend_message` · `get_usage` |
282
- | `client.chat` | Conversations with the AI accountant: questions, streaming chat (SSE), token counting and history | `list / list_all` · `create / create_stream` · `count_tokens` · `get` · `update` · `delete` · `answer / answer_stream` · `list_events` · `stop` |
283
- | `client.proposals` | Documents proposed by the AI accountant: review, approval for posting to 1C, and rejection | `list / list_all` · `approve_batch` · `get` · `approve` · `reject` |
282
+ | `client.chat` | Conversations with the AI accountant: questions, streaming chat (SSE), token counting and history | `list / list_all` · `create / create_stream` · `count_tokens` · `list_mentions` · `get_rating_options` · `list_suggestions` · `get` · `update` · `delete` · `answer / answer_stream` · `list_events` · `rate_message` · `delete_message_rating` · `rate` · `dismiss_rating` · `stop` |
283
+ | `client.proposals` | Documents proposed by the AI accountant: review, approval for posting to 1C, and rejection | `list / list_all` · `approve_batch` · `get` · `approve` · `reject` · `request_approval` |
284
284
  | `client.feed` | The company's feed of events and proposals (pages and a live SSE stream) | `get / get_all` · `list_events` |
285
285
  | `client.batches` | Processing batches for bank statements, incoming e-invoices and DirectBank | `list / list_all` · `create_bank_statement` · `create_esf_purchases` · `get` · `list_events` · `stop` · `get_summary` · `list_statements / list_statements_all` · `poll_directbank` |
286
286
  | `client.esf` | Incoming and outgoing electronic invoices (the ESF system) | `get_incoming / get_incoming_all` · `get_outgoing / get_outgoing_all` |
@@ -307,7 +307,7 @@ The same API is available in ten languages. All SDKs are generated from one cont
307
307
 
308
308
  ## Versioning and support
309
309
 
310
- This library follows [Semantic Versioning](https://semver.org/). While the major version is 0, a minor release may contain breaking changes; they are always listed in the [changelog](https://github.com/TungoAI/tungo-sdk-ruby/blob/main/CHANGELOG.md). This README describes version 0.2.0.
310
+ This library follows [Semantic Versioning](https://semver.org/). While the major version is 0, a minor release may contain breaking changes; they are always listed in the [changelog](https://github.com/TungoAI/tungo-sdk-ruby/blob/main/CHANGELOG.md). This README describes version 0.3.1.
311
311
 
312
312
  The code is generated: please report problems and ideas in the [issue tracker](https://github.com/TungoAI/tungo-sdk-ruby/issues) rather than opening pull requests against generated files. To report a vulnerability, follow the [security policy](https://github.com/TungoAI/tungo-sdk-ruby/blob/main/SECURITY.md).
313
313
 
data/lib/tungo/client.rb CHANGED
@@ -172,7 +172,7 @@ module Tungo
172
172
  "Cache-Control" => "no-cache")
173
173
  call = prepare(options: options, accept: "text/event-stream", headers: headers, **spec)
174
174
  response, = perform(call, options, timeout: nil, streaming: true)
175
- check_event_stream(response)
175
+ response = check_event_stream(response)
176
176
  stream_class.new(response: response, decode: event_decoder(event))
177
177
  end
178
178
 
@@ -235,13 +235,16 @@ module Tungo
235
235
 
236
236
  all = { "accept" => accept, "user-agent" => USER_AGENT }.merge(default_headers_for(auth))
237
237
  all["x-api-key"] = api_key! if auth == :key
238
- key = options.idempotency_key || idempotency_key(idempotency_header, idempotency_default)
239
- all[(idempotency_header || "Idempotency-Key").downcase] = key if key
238
+ # A key goes only to an operation that declares the header: anywhere else the API ignores
239
+ # it, and sending it would make a retry look safe when it repeats the action.
240
+ key = idempotency_header && (options.idempotency_key || idempotency_key(idempotency_default, body))
241
+ all[idempotency_header.downcase] = key if key
240
242
  payload, type = encode_body(body, body_required, raw_body, content_type)
241
243
  all["content-type"] = type if payload && type
242
- all[signature_header.downcase] = Webhooks.sign_hook_payload(payload || "", secret) if signature_header && secret
244
+ Internal::Util.sign_hook(all, headers, payload, signature_header, secret) if signature_header
243
245
  merge_headers(all, headers)
244
246
  merge_headers(all, options.extra_headers)
247
+ all.delete("idempotency-key") unless idempotency_header
245
248
  Call.new(verb: method.to_s.upcase, route: path, url: url, headers: all, body: payload, keyed: !key.nil?)
246
249
  end
247
250
 
@@ -252,10 +255,10 @@ module Tungo
252
255
  auth == :key ? @default_headers : @default_headers.except(*Transport::CREDENTIAL_HEADERS)
253
256
  end
254
257
 
255
- def idempotency_key(header, default)
256
- return nil if header.nil?
258
+ def idempotency_key(default, body)
259
+ return default if default.is_a?(String) && !default.empty?
257
260
 
258
- default.is_a?(String) && !default.empty? ? default : SecureRandom.uuid
261
+ Internal::Util.body_idempotency_key(body) || SecureRandom.uuid
259
262
  end
260
263
 
261
264
  def encode_body(body, body_required, raw_body, content_type)
@@ -375,9 +378,14 @@ module Tungo
375
378
  "(#{e.class})", api_response: api_response, body: body)
376
379
  end
377
380
 
381
+ # Returns the response when it is an event stream. A chat turn repeated with the same
382
+ # Idempotency-Key after it finished is answered with the stored ChatTurnResult instead: it
383
+ # becomes the event stream of that turn. Anything else is a DecodeError.
378
384
  def check_event_stream(response)
385
+ return Internal::ChatReplay.event_stream(response) if Internal::ChatReplay.replay?(response)
386
+
379
387
  type = response.headers["content-type"].to_s
380
- return if type.split(";").first.to_s.strip.casecmp?("text/event-stream")
388
+ return response if type.split(";").first.to_s.strip.casecmp?("text/event-stream")
381
389
 
382
390
  body = begin
383
391
  response.read
data/lib/tungo/helpers.rb CHANGED
@@ -27,12 +27,14 @@ module Tungo
27
27
  end
28
28
 
29
29
  # Posts an event to an incoming hook (+POST /hooks/{token}+). The API key is never sent.
30
- # With a +secret+ the exact bytes of the body are signed in the +X-Signature+ header.
30
+ # With a +secret+ the exact bytes of the body are signed in the +X-Signature+ header, or in
31
+ # +signature_header:+ for a hook created with its own signature_header.
31
32
  #
32
33
  # @param token [String] the hook token (+th_...+)
33
34
  # @param payload [String, Hash, Array, Tungo::Model, nil] a String is sent byte for byte;
34
35
  # anything else is sent as JSON
35
36
  # @param secret [String, nil] the hook's signing secret
37
+ # @param signature_header [String, nil] the hook's own signature_header (default X-Signature)
36
38
  # @param options [Hash] the other keyword arguments of +automations.post_hook+
37
39
  # @return [Tungo::Models::AutomationHookAccepted]
38
40
  def send_hook(token, payload = nil, secret: nil, **)
@@ -118,5 +118,96 @@ module Tungo
118
118
  retry: retry_ms)
119
119
  end
120
120
  end
121
+
122
+ # A stream call repeated with the same Idempotency-Key after its chat turn finished: the
123
+ # server answers the stored ChatTurnResult as JSON with Idempotent-Replayed: true.
124
+ module ChatReplay
125
+ module_function
126
+
127
+ # Whether a stream call was answered with a stored result replayed by Idempotency-Key.
128
+ def replay?(response)
129
+ type = response.headers["content-type"].to_s.split(";").first.to_s.strip
130
+ type.casecmp?("application/json") && response.headers["idempotent-replayed"].to_s.strip.casecmp?("true")
131
+ end
132
+
133
+ # Turns a replayed ChatTurnResult into the event stream of the turn it stands for: text (the
134
+ # answer), proposal, question, citation, error, choice and next events, then done. The dialog id
135
+ # and the turn number, which a replay carries only in the body, become the X-Dialog-Id and
136
+ # X-Turn-No headers when they are missing.
137
+ #
138
+ # @raise [Tungo::DecodeError] when the body is not a chat turn result
139
+ def event_stream(response)
140
+ body = begin
141
+ response.read
142
+ ensure
143
+ response.close
144
+ end
145
+ result = parse(body)
146
+ unless result.is_a?(Hash) && result["dialog_id"].is_a?(String)
147
+ raise DecodeError.new("The API replayed status #{response.status} to a stream request with a body that " \
148
+ "is not a chat turn result",
149
+ api_response: APIResponse.new(status: response.status, headers: response.headers),
150
+ body: body)
151
+ end
152
+ headers = response.headers.dup
153
+ headers["x-dialog-id"] = result["dialog_id"] if headers["x-dialog-id"].to_s.empty?
154
+ turn_no = result["turn_no"]
155
+ headers["x-turn-no"] = turn_no.to_s if turn_no.is_a?(Integer) && headers["x-turn-no"].to_s.empty?
156
+ Transport::Response.new(status: response.status, headers: headers, chunks: [events(result, headers)])
157
+ end
158
+
159
+ def parse(body)
160
+ Util.parse_json(Util.text(body))
161
+ rescue JSON::ParserError, EncodingError, ArgumentError
162
+ nil
163
+ end
164
+
165
+ def events(result, headers)
166
+ out = +""
167
+ emit = ->(type, event) { out << "event: #{type}\ndata: #{Util.generate_json(event.merge("type" => type))}\n\n" }
168
+ entries = ->(key) { result[key].is_a?(Array) ? result[key].grep(Hash) : [] }
169
+ answer = result["answer"].is_a?(String) ? result["answer"] : ""
170
+ emit.call("text", { "delta" => answer }) unless answer.empty?
171
+ entries.call("proposals").each do |proposal|
172
+ emit.call("proposal", proposal.except("id").merge("proposal_id" => proposal["id"]))
173
+ end
174
+ entries.call("questions").each { |question| emit.call("question", question) }
175
+ entries.call("citations").each { |citation| emit.call("citation", citation) }
176
+ request_id = headers["x-request-id"].to_s
177
+ entries.call("errors").each do |error|
178
+ emit.call("error", { "error" => error, "request_id" => request_id.empty? ? nil : request_id })
179
+ end
180
+ emit.call("done", done(result, answer, emit))
181
+ out
182
+ end
183
+
184
+ # The next event of a live turn, which ends its finished answer right before done: the stored
185
+ # result keeps it as followups and next_action.
186
+ def next_event(result, emit)
187
+ followups = result["followups"].is_a?(Array) ? result["followups"] : []
188
+ action = result["next_action"].is_a?(Hash) ? result["next_action"] : nil
189
+ return if followups.empty? && action.nil?
190
+
191
+ emit.call("next", { "followups" => followups, "action" => action })
192
+ end
193
+
194
+ # The done event; emits the choice event of an open question and the next event first.
195
+ def done(result, answer, emit)
196
+ event = { "answer" => answer }
197
+ event["stop_reason"] = result["stop_reason"] if result["stop_reason"].is_a?(String)
198
+ usage = result["usage"]
199
+ if usage.is_a?(Hash)
200
+ event["usage"] = usage.except("cost_tiyn")
201
+ event["cost_tiyn"] = usage["cost_tiyn"] if usage.key?("cost_tiyn")
202
+ end
203
+ pending = result["pending_question"]
204
+ if pending.is_a?(Hash)
205
+ emit.call("choice", pending)
206
+ event["choice_id"] = pending["choice_id"] if pending.key?("choice_id")
207
+ end
208
+ next_event(result, emit)
209
+ event
210
+ end
211
+ end
121
212
  end
122
213
  end
@@ -58,6 +58,7 @@ module Tungo
58
58
  SAFE_METHODS = %w[GET HEAD PUT DELETE].freeze
59
59
  NUMBER = /\A[0-9]+(\.[0-9]+)?\z/
60
60
  UNRESERVED = /[^A-Za-z0-9\-._~]/n
61
+ HOOK_SIGNATURE_HEADER = /\A[A-Za-z0-9-]{1,64}\z/
61
62
 
62
63
  module_function
63
64
 
@@ -197,6 +198,36 @@ module Tungo
197
198
  end
198
199
  end
199
200
 
201
+ # Signs a hook body into +name+, the header the hook reads its signature from (the
202
+ # signature_header it was created with).
203
+ def sign_hook(all, headers, payload, name, secret)
204
+ unless name.is_a?(String) && name.match?(HOOK_SIGNATURE_HEADER)
205
+ raise ValidationError, "signature_header must be 1 to 64 Latin letters, digits or hyphens"
206
+ end
207
+ return unless secret
208
+
209
+ given = (headers || {}).any? do |header, value|
210
+ header.to_s.casecmp?(name) && !value.nil? && !OMIT.equal?(value)
211
+ end
212
+ raise ValidationError, "Pass either secret or signature, not both" if given
213
+
214
+ all[name.downcase] = Webhooks.sign_hook_payload(payload || "", secret)
215
+ end
216
+
217
+ # The idempotency_key field of a JSON object body (approving a proposal documents it as the
218
+ # same as the header), trimmed like the API trims it. The API prefers the header over the
219
+ # field, so a generated header would make the caller's own key useless. A key that cannot
220
+ # travel in a header (outside printable ASCII) is ignored here.
221
+ def body_idempotency_key(body)
222
+ return nil unless body.is_a?(Hash)
223
+
224
+ value = body.find { |name, _| name.to_s == "idempotency_key" }&.last
225
+ return nil unless value.is_a?(String)
226
+
227
+ key = value.strip
228
+ key if key.match?(/\A[\x20-\x7e]+\z/)
229
+ end
230
+
200
231
  # A secret that is sent as a header value (the API key) must be printable ASCII without
201
232
  # spaces. A trailing line break from a file or a secret store is the usual mistake; it is
202
233
  # refused here, by name only: the secret itself is never printed.
@@ -19,7 +19,8 @@ module Tungo
19
19
  required :allowed_ips, array_of(:string), nullable: true
20
20
 
21
21
  # @!attribute [r] company_ids
22
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
22
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
23
+ # ключа без компаний (no_companies)
23
24
  # @return [Array<String>]
24
25
  required :company_ids, array_of(:string)
25
26
 
@@ -71,6 +72,13 @@ module Tungo
71
72
  # @return [String]
72
73
  required :name, :string
73
74
 
75
+ # @!attribute [r] no_companies
76
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
77
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
78
+ # no_companies
79
+ # @return [Boolean]
80
+ required :no_companies, :boolean
81
+
74
82
  # @!attribute [r] permissions
75
83
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
76
84
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -43,12 +43,19 @@ module Tungo
43
43
  # @return [String]
44
44
  required :name, :string
45
45
 
46
+ # @!attribute [r] no_companies
47
+ # Ключ без доступа к компаниям и их 1С: ни одной компании он не видит — ни сейчас, ни будущих;
48
+ # company_ids и all_companies не передаются, права — только company.read (он ничего не
49
+ # открывает). По умолчанию false
50
+ # @return [Boolean, nil]
51
+ optional :no_companies, :boolean
52
+
46
53
  # @!attribute [r] permissions
47
54
  # Права ключа (1–20): `company.read` — читать данные компаний (добавляется всегда, даже если не
48
55
  # передано); `chat.use` — работать с ИИ-бухгалтером; `proposals.create` — готовить документы для
49
56
  # 1С; `proposals.approve` — одобр…
50
- # @return [Array<String>]
51
- required :permissions, array_of(:string)
57
+ # @return [Array<String>, nil]
58
+ optional :permissions, array_of(:string)
52
59
 
53
60
  # @!attribute [r] write_kinds
54
61
  # Предел записи в 1С по ключу: какие виды документов ключ может одобрять (как kinds правила
@@ -19,7 +19,8 @@ module Tungo
19
19
  required :allowed_ips, array_of(:string), nullable: true
20
20
 
21
21
  # @!attribute [r] company_ids
22
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
22
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
23
+ # ключа без компаний (no_companies)
23
24
  # @return [Array<String>]
24
25
  required :company_ids, array_of(:string)
25
26
 
@@ -83,6 +84,13 @@ module Tungo
83
84
  # @return [String]
84
85
  required :name, :string
85
86
 
87
+ # @!attribute [r] no_companies
88
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
89
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
90
+ # no_companies
91
+ # @return [Boolean]
92
+ required :no_companies, :boolean
93
+
86
94
  # @!attribute [r] permissions
87
95
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
88
96
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -26,7 +26,8 @@ module Tungo
26
26
  required :blocked_reason, :ApiKeyDetailsBlockedReason, nullable: true
27
27
 
28
28
  # @!attribute [r] company_ids
29
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
29
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
30
+ # ключа без компаний (no_companies)
30
31
  # @return [Array<String>]
31
32
  required :company_ids, array_of(:string)
32
33
 
@@ -78,6 +79,13 @@ module Tungo
78
79
  # @return [String]
79
80
  required :name, :string
80
81
 
82
+ # @!attribute [r] no_companies
83
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
84
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
85
+ # no_companies
86
+ # @return [Boolean]
87
+ required :no_companies, :boolean
88
+
81
89
  # @!attribute [r] permissions
82
90
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
83
91
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -46,6 +46,13 @@ module Tungo
46
46
  # @return [String, nil]
47
47
  optional :name, :string
48
48
 
49
+ # @!attribute [r] no_companies
50
+ # Ключ без доступа к компаниям и их 1С: ни одной компании он не видит — ни сейчас, ни будущих;
51
+ # company_ids и all_companies не передаются, права — только company.read (он ничего не
52
+ # открывает). true — ключ теряет доступ ко в…
53
+ # @return [Boolean, nil]
54
+ optional :no_companies, :boolean
55
+
49
56
  # @!attribute [r] permissions
50
57
  # Права ключа (1–20): `company.read` — читать данные компаний (добавляется всегда, даже если не
51
58
  # передано); `chat.use` — работать с ИИ-бухгалтером; `proposals.create` — готовить документы для
@@ -19,7 +19,8 @@ module Tungo
19
19
  required :allowed_ips, array_of(:string), nullable: true
20
20
 
21
21
  # @!attribute [r] company_ids
22
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
22
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
23
+ # ключа без компаний (no_companies)
23
24
  # @return [Array<String>]
24
25
  required :company_ids, array_of(:string)
25
26
 
@@ -50,9 +51,16 @@ module Tungo
50
51
  required :id, :string
51
52
 
52
53
  # @!attribute [r] key
53
- # Новый ключ целиком (tg_…) — один раз: показать с кнопкой «Скопировать»
54
- # @return [String]
55
- required :key, :string
54
+ # Новый ключ целиком (tg_…) — один раз: показать с кнопкой «Скопировать». В повторе по
55
+ # Idempotency-Key — null
56
+ # @return [String, nil]
57
+ required :key, :string, nullable: true
58
+
59
+ # @!attribute [r] key_note
60
+ # Только в повторе по Idempotency-Key: почему key = null и что делать, если новый секрет потерян
61
+ # (сменить ещё раз)
62
+ # @return [String, nil]
63
+ optional :key_note, :string
56
64
 
57
65
  # @!attribute [r] last_used_at
58
66
  # Когда ключом пользовались последний раз, ISO 8601 UTC (точность — около минуты); null — ещё ни
@@ -76,6 +84,13 @@ module Tungo
76
84
  # @return [String]
77
85
  required :name, :string
78
86
 
87
+ # @!attribute [r] no_companies
88
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
89
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
90
+ # no_companies
91
+ # @return [Boolean]
92
+ required :no_companies, :boolean
93
+
79
94
  # @!attribute [r] permissions
80
95
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
81
96
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -26,7 +26,8 @@ module Tungo
26
26
  required :blocked_reason, :ApiKeySelfBlockedReason, nullable: true
27
27
 
28
28
  # @!attribute [r] company_ids
29
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
29
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
30
+ # ключа без компаний (no_companies)
30
31
  # @return [Array<String>]
31
32
  required :company_ids, array_of(:string)
32
33
 
@@ -82,6 +83,13 @@ module Tungo
82
83
  # @return [String]
83
84
  required :name, :string
84
85
 
86
+ # @!attribute [r] no_companies
87
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
88
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
89
+ # no_companies
90
+ # @return [Boolean]
91
+ required :no_companies, :boolean
92
+
85
93
  # @!attribute [r] permissions
86
94
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
87
95
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -19,7 +19,8 @@ module Tungo
19
19
  required :allowed_ips, array_of(:string), nullable: true
20
20
 
21
21
  # @!attribute [r] company_ids
22
- # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies)
22
+ # Компании, к которым ключ даёт доступ (co_…); пусто у ключа на все компании (all_companies) и у
23
+ # ключа без компаний (no_companies)
23
24
  # @return [Array<String>]
24
25
  required :company_ids, array_of(:string)
25
26
 
@@ -71,6 +72,13 @@ module Tungo
71
72
  # @return [String]
72
73
  required :name, :string
73
74
 
75
+ # @!attribute [r] no_companies
76
+ # Ключ без доступа к компаниям и их 1С: company_ids пуст, all_companies = false; компаний не
77
+ # видит никогда. Пустой company_ids сам по себе вида не называет — смотреть на all_companies и
78
+ # no_companies
79
+ # @return [Boolean]
80
+ required :no_companies, :boolean
81
+
74
82
  # @!attribute [r] permissions
75
83
  # Права ключа: `company.read` — читать данные компаний (есть всегда); `chat.use` — работать с
76
84
  # ИИ-бухгалтером; `proposals.create` — готовить документы для 1С; `proposals.approve` — одобрять
@@ -12,7 +12,7 @@ module Tungo
12
12
  required :cost_tiyn, :integer
13
13
 
14
14
  # @!attribute [r] model
15
- # Модель ИИ (техническое имя)
15
+ # Модель ИИ: tungo-1-flash, tungo-1, tungo-1-deep (tungo-search, tungo-legacy)
16
16
  # @return [String]
17
17
  required :model, :string
18
18