noresponse 8.1.2 → 8.2.0

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/lib/no_response/accounts.rb +2068 -0
  3. data/lib/no_response/assessments.rb +890 -0
  4. data/lib/no_response/lists.rb +2 -2
  5. data/lib/no_response/models/operations/associatecredential_request.rb +33 -0
  6. data/lib/no_response/models/operations/associatecredential_request.rbi +20 -0
  7. data/lib/no_response/models/operations/associatecredential_response.rb +34 -0
  8. data/lib/no_response/models/operations/associatecredential_response.rbi +20 -0
  9. data/lib/no_response/models/operations/bindprovisionalaccount_request.rb +37 -0
  10. data/lib/no_response/models/operations/bindprovisionalaccount_request.rbi +20 -0
  11. data/lib/no_response/models/operations/bindprovisionalaccount_response.rb +32 -0
  12. data/lib/no_response/models/operations/bindprovisionalaccount_response.rbi +20 -0
  13. data/lib/no_response/models/operations/exportaccount_request.rb +37 -0
  14. data/lib/no_response/models/operations/exportaccount_request.rbi +20 -0
  15. data/lib/no_response/models/operations/exportaccount_response.rb +32 -0
  16. data/lib/no_response/models/operations/exportaccount_response.rbi +20 -0
  17. data/lib/no_response/models/operations/getaccountdecision_request.rb +37 -0
  18. data/lib/no_response/models/operations/getaccountdecision_request.rbi +20 -0
  19. data/lib/no_response/models/operations/getaccountdecision_response.rb +34 -0
  20. data/lib/no_response/models/operations/getaccountdecision_response.rbi +20 -0
  21. data/lib/no_response/models/operations/getassessmentversion_request.rb +48 -0
  22. data/lib/no_response/models/operations/getassessmentversion_request.rbi +26 -0
  23. data/lib/no_response/models/operations/getassessmentversion_response.rb +32 -0
  24. data/lib/no_response/models/operations/getassessmentversion_response.rbi +20 -0
  25. data/lib/no_response/models/operations/listaccountcredentials_request.rb +45 -0
  26. data/lib/no_response/models/operations/listaccountcredentials_request.rbi +26 -0
  27. data/lib/no_response/models/operations/listaccountcredentials_response.rb +32 -0
  28. data/lib/no_response/models/operations/listaccountcredentials_response.rbi +20 -0
  29. data/lib/no_response/models/operations/listaccountoutcomes_request.rb +45 -0
  30. data/lib/no_response/models/operations/listaccountoutcomes_request.rbi +26 -0
  31. data/lib/no_response/models/operations/listaccountoutcomes_response.rb +32 -0
  32. data/lib/no_response/models/operations/listaccountoutcomes_response.rbi +20 -0
  33. data/lib/no_response/models/operations/listrequestdiagnostics_request.rb +84 -0
  34. data/lib/no_response/models/operations/listrequestdiagnostics_request.rbi +50 -0
  35. data/lib/no_response/models/operations/listrequestdiagnostics_response.rb +34 -0
  36. data/lib/no_response/models/operations/listrequestdiagnostics_response.rbi +20 -0
  37. data/lib/no_response/models/operations/recordaccountoutcome_request.rb +48 -0
  38. data/lib/no_response/models/operations/recordaccountoutcome_request.rbi +26 -0
  39. data/lib/no_response/models/operations/recordaccountoutcome_response.rb +32 -0
  40. data/lib/no_response/models/operations/recordaccountoutcome_response.rbi +20 -0
  41. data/lib/no_response/models/operations/retireaccountcredential_request.rb +37 -0
  42. data/lib/no_response/models/operations/retireaccountcredential_request.rbi +20 -0
  43. data/lib/no_response/models/operations/retireaccountcredential_response.rb +34 -0
  44. data/lib/no_response/models/operations/retireaccountcredential_response.rbi +20 -0
  45. data/lib/no_response/models/operations/searchassessments_response.rb +32 -0
  46. data/lib/no_response/models/operations/searchassessments_response.rbi +20 -0
  47. data/lib/no_response/models/operations.rb +21 -0
  48. data/lib/no_response/models/shared/accountbinding.rb +83 -0
  49. data/lib/no_response/models/shared/accountbinding.rbi +44 -0
  50. data/lib/no_response/models/shared/accountbindingactor.rb +40 -0
  51. data/lib/no_response/models/shared/accountbindingactor.rbi +20 -0
  52. data/lib/no_response/models/shared/accountbindingrequest.rb +33 -0
  53. data/lib/no_response/models/shared/accountbindingrequest.rbi +14 -0
  54. data/lib/no_response/models/shared/accountdecisionsnapshot.rb +94 -0
  55. data/lib/no_response/models/shared/accountdecisionsnapshot.rbi +44 -0
  56. data/lib/no_response/models/shared/accountexport.rb +178 -0
  57. data/lib/no_response/models/shared/accountexport.rbi +92 -0
  58. data/lib/no_response/models/shared/accountoutcome.rb +152 -0
  59. data/lib/no_response/models/shared/accountoutcome.rbi +80 -0
  60. data/lib/no_response/models/shared/accountoutcomeactor.rb +40 -0
  61. data/lib/no_response/models/shared/accountoutcomeactor.rbi +20 -0
  62. data/lib/no_response/models/shared/accountoutcomepage.rb +65 -0
  63. data/lib/no_response/models/shared/accountoutcomepage.rbi +32 -0
  64. data/lib/no_response/models/shared/accountoutcomerequest.rb +71 -0
  65. data/lib/no_response/models/shared/accountoutcomerequest.rbi +32 -0
  66. data/lib/no_response/models/shared/assessmentrevision.rb +101 -0
  67. data/lib/no_response/models/shared/assessmentrevision.rbi +44 -0
  68. data/lib/no_response/models/shared/assessmentsearchpage.rb +68 -0
  69. data/lib/no_response/models/shared/assessmentsearchpage.rbi +32 -0
  70. data/lib/no_response/models/shared/assessmentsearchrequest.rb +146 -0
  71. data/lib/no_response/models/shared/assessmentsearchrequest.rbi +68 -0
  72. data/lib/no_response/models/shared/conflicterrorcode.rb +4 -0
  73. data/lib/no_response/models/shared/credentialassociation.rb +78 -0
  74. data/lib/no_response/models/shared/credentialassociation.rbi +44 -0
  75. data/lib/no_response/models/shared/credentialassociationactor.rb +40 -0
  76. data/lib/no_response/models/shared/credentialassociationactor.rbi +20 -0
  77. data/lib/no_response/models/shared/credentialassociationretiredby.rb +40 -0
  78. data/lib/no_response/models/shared/credentialassociationretiredby.rbi +20 -0
  79. data/lib/no_response/models/shared/credentialpage.rb +56 -0
  80. data/lib/no_response/models/shared/credentialpage.rbi +26 -0
  81. data/lib/no_response/models/shared/credentialrequest.rb +32 -0
  82. data/lib/no_response/models/shared/credentialrequest.rbi +14 -0
  83. data/lib/no_response/models/shared/decision.rb +18 -0
  84. data/lib/no_response/models/shared/decision.rbi +9 -0
  85. data/lib/no_response/models/shared/decisionreceipt.rb +112 -0
  86. data/lib/no_response/models/shared/decisionreceipt.rbi +50 -0
  87. data/lib/no_response/models/shared/exclusion.rb +23 -0
  88. data/lib/no_response/models/shared/exclusion.rbi +9 -0
  89. data/lib/no_response/models/shared/exportassessmentoutcome.rb +85 -0
  90. data/lib/no_response/models/shared/exportassessmentoutcome.rbi +44 -0
  91. data/lib/no_response/models/shared/reasoncode.rb +1 -0
  92. data/lib/no_response/models/shared/requestdiagnostic.rb +145 -0
  93. data/lib/no_response/models/shared/requestdiagnostic.rbi +80 -0
  94. data/lib/no_response/models/shared/requestdiagnosticpage.rb +40 -0
  95. data/lib/no_response/models/shared/requestdiagnosticpage.rbi +20 -0
  96. data/lib/no_response/models/shared.rb +23 -0
  97. data/lib/no_response/noresponseclient.rb +12 -1
  98. data/lib/no_response/requests.rb +320 -0
  99. data/lib/no_response/sdkconfiguration.rb +2 -2
  100. data/lib/noresponse.rb +1 -0
  101. metadata +91 -2
@@ -1530,5 +1530,2073 @@ module NoResponse
1530
1530
 
1531
1531
  end
1532
1532
  end
1533
+
1534
+ sig {
1535
+ params(
1536
+ body: Models::Shared::AccountOutcomeRequest,
1537
+ account_id: ::String,
1538
+ idempotency_key: T.nilable(::String),
1539
+ retries: T.nilable(Utils::RetryConfig),
1540
+ timeout_ms: T.nilable(Integer),
1541
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1542
+ )
1543
+ .returns(Models::Operations::RecordAccountOutcomeResponse)
1544
+ }
1545
+ def record_outcome(body:, account_id:, idempotency_key: nil, retries: nil, timeout_ms: nil, http_headers: nil)
1546
+ # record_outcome - Record or correct an account outcome
1547
+ # Record a factual report, not an enforcement action. A known outcome replaces the effective report. unknown alone records uncertainty without changing it; unknown with supersedes explicitly retracts it. supersedes must name the current effective report or the request answers 409 outcome_conflict. Reports remain append-only. Idempotency-Key is required. observed_at defaults to receipt time and cannot be over five minutes ahead.
1548
+ request = Models::Operations::RecordAccountOutcomeRequest.new(
1549
+ account_id: account_id,
1550
+ body: body,
1551
+ idempotency_key: idempotency_key
1552
+ )
1553
+ url, params = @sdk_configuration.get_server_details
1554
+ base_url = Utils.template_url(url, params)
1555
+ url = Utils.generate_url(
1556
+ Models::Operations::RecordAccountOutcomeRequest,
1557
+ base_url,
1558
+ "/v1/accounts/{account_id}/outcomes",
1559
+ request
1560
+ )
1561
+ headers = Utils.get_headers(request)
1562
+ headers = T.cast(headers, T::Hash[String, String])
1563
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
1564
+ headers["content-type"] = req_content_type
1565
+ raise StandardError, "request body is required" if data.nil? && form.nil?
1566
+
1567
+ if form && !form.empty?
1568
+ body = Utils.encode_form(form)
1569
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
1570
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
1571
+ else
1572
+ body = data
1573
+ end
1574
+
1575
+ headers["Accept"] = "application/json"
1576
+ headers["user-agent"] = @sdk_configuration.user_agent
1577
+ retries ||= @sdk_configuration.retry_config
1578
+ retries ||= Utils::RetryConfig.new(
1579
+ backoff: Utils::BackoffStrategy.new(
1580
+ exponent: 2.0,
1581
+ initial_interval: 500,
1582
+ max_elapsed_time: 30_000,
1583
+ max_interval: 8000
1584
+ ),
1585
+ retry_connection_errors: true,
1586
+ strategy: "backoff"
1587
+ )
1588
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1589
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1590
+
1591
+ security = @sdk_configuration.security_source&.call
1592
+
1593
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1594
+ timeout ||= @sdk_configuration.timeout
1595
+
1596
+ connection = @sdk_configuration.client.dup
1597
+ connection.use(Utils::RetryMiddleware, retry_options)
1598
+
1599
+ hook_ctx = SDKHooks::HookContext.new(
1600
+ config: @sdk_configuration,
1601
+ base_url: base_url,
1602
+ oauth2_scopes: nil,
1603
+ operation_id: "recordAccountOutcome",
1604
+ security_source: @sdk_configuration.security_source
1605
+ )
1606
+
1607
+ error = T.let(nil, T.nilable(StandardError))
1608
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1609
+
1610
+ begin
1611
+ http_response = T.must(connection).post(url) do |req|
1612
+ req.body = body
1613
+ req.headers.merge!(headers)
1614
+ req.options.timeout = timeout unless timeout.nil?
1615
+ Utils.configure_request_security(req, security)
1616
+ http_headers&.each do |key, value|
1617
+ req.headers[key.to_s] = value
1618
+ end
1619
+
1620
+ @sdk_configuration.hooks.before_request(
1621
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1622
+ hook_ctx: hook_ctx
1623
+ ),
1624
+ request: req
1625
+ )
1626
+ end
1627
+
1628
+ rescue StandardError => e
1629
+ error = e
1630
+ ensure
1631
+ if http_response.nil? || Utils.error_status?(http_response.status)
1632
+ http_response = @sdk_configuration.hooks.after_error(
1633
+ error: error,
1634
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1635
+ hook_ctx: hook_ctx
1636
+ ),
1637
+ response: http_response
1638
+ )
1639
+ else
1640
+ http_response = @sdk_configuration.hooks.after_success(
1641
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1642
+ hook_ctx: hook_ctx
1643
+ ),
1644
+ response: http_response
1645
+ )
1646
+ end
1647
+
1648
+ if http_response.nil?
1649
+ raise error if !error.nil?
1650
+ raise "no response"
1651
+ end
1652
+ end
1653
+
1654
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1655
+ if Utils.match_status_code(http_response.status, ["202"])
1656
+ if Utils.match_content_type(content_type, "application/json")
1657
+ @sdk_configuration.hooks.after_success(
1658
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1659
+ hook_ctx: hook_ctx
1660
+ ),
1661
+ response: http_response
1662
+ )
1663
+ response_data = http_response.env.response_body
1664
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AccountOutcome)
1665
+ result = obj
1666
+ response = Models::Operations::RecordAccountOutcomeResponse.new(
1667
+ result: result,
1668
+ headers: http_response.headers
1669
+ )
1670
+
1671
+ return response
1672
+ else
1673
+ raise(
1674
+ ::NoResponse::Models::Errors::APIStatusError.new(
1675
+ status_code: http_response.status,
1676
+ body: http_response.env.response_body,
1677
+ raw_response: http_response
1678
+ ),
1679
+ "Unknown content type received"
1680
+ )
1681
+ end
1682
+ elsif Utils.match_status_code(http_response.status, ["400"])
1683
+ if Utils.match_content_type(content_type, "application/problem+json")
1684
+ @sdk_configuration.hooks.after_success(
1685
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1686
+ hook_ctx: hook_ctx
1687
+ ),
1688
+ response: http_response
1689
+ )
1690
+ response_data = http_response.env.response_body
1691
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1692
+ raise obj
1693
+ else
1694
+ raise(
1695
+ ::NoResponse::Models::Errors::APIStatusError.new(
1696
+ status_code: http_response.status,
1697
+ body: http_response.env.response_body,
1698
+ raw_response: http_response
1699
+ ),
1700
+ "Unknown content type received"
1701
+ )
1702
+ end
1703
+ elsif Utils.match_status_code(http_response.status, ["401"])
1704
+ if Utils.match_content_type(content_type, "application/problem+json")
1705
+ @sdk_configuration.hooks.after_success(
1706
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1707
+ hook_ctx: hook_ctx
1708
+ ),
1709
+ response: http_response
1710
+ )
1711
+ response_data = http_response.env.response_body
1712
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
1713
+ raise obj
1714
+ else
1715
+ raise(
1716
+ ::NoResponse::Models::Errors::APIStatusError.new(
1717
+ status_code: http_response.status,
1718
+ body: http_response.env.response_body,
1719
+ raw_response: http_response
1720
+ ),
1721
+ "Unknown content type received"
1722
+ )
1723
+ end
1724
+ elsif Utils.match_status_code(http_response.status, ["403"])
1725
+ if Utils.match_content_type(content_type, "application/problem+json")
1726
+ @sdk_configuration.hooks.after_success(
1727
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1728
+ hook_ctx: hook_ctx
1729
+ ),
1730
+ response: http_response
1731
+ )
1732
+ response_data = http_response.env.response_body
1733
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
1734
+ raise obj
1735
+ else
1736
+ raise(
1737
+ ::NoResponse::Models::Errors::APIStatusError.new(
1738
+ status_code: http_response.status,
1739
+ body: http_response.env.response_body,
1740
+ raw_response: http_response
1741
+ ),
1742
+ "Unknown content type received"
1743
+ )
1744
+ end
1745
+ elsif Utils.match_status_code(http_response.status, ["404"])
1746
+ if Utils.match_content_type(content_type, "application/problem+json")
1747
+ @sdk_configuration.hooks.after_success(
1748
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1749
+ hook_ctx: hook_ctx
1750
+ ),
1751
+ response: http_response
1752
+ )
1753
+ response_data = http_response.env.response_body
1754
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
1755
+ raise obj
1756
+ else
1757
+ raise(
1758
+ ::NoResponse::Models::Errors::APIStatusError.new(
1759
+ status_code: http_response.status,
1760
+ body: http_response.env.response_body,
1761
+ raw_response: http_response
1762
+ ),
1763
+ "Unknown content type received"
1764
+ )
1765
+ end
1766
+ elsif Utils.match_status_code(http_response.status, ["409"])
1767
+ if Utils.match_content_type(content_type, "application/problem+json")
1768
+ @sdk_configuration.hooks.after_success(
1769
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1770
+ hook_ctx: hook_ctx
1771
+ ),
1772
+ response: http_response
1773
+ )
1774
+ response_data = http_response.env.response_body
1775
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
1776
+ raise obj
1777
+ else
1778
+ raise(
1779
+ ::NoResponse::Models::Errors::APIStatusError.new(
1780
+ status_code: http_response.status,
1781
+ body: http_response.env.response_body,
1782
+ raw_response: http_response
1783
+ ),
1784
+ "Unknown content type received"
1785
+ )
1786
+ end
1787
+ elsif Utils.match_status_code(http_response.status, ["429"])
1788
+ if Utils.match_content_type(content_type, "application/problem+json")
1789
+ @sdk_configuration.hooks.after_success(
1790
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1791
+ hook_ctx: hook_ctx
1792
+ ),
1793
+ response: http_response
1794
+ )
1795
+ response_data = http_response.env.response_body
1796
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
1797
+ raise obj
1798
+ else
1799
+ raise(
1800
+ ::NoResponse::Models::Errors::APIStatusError.new(
1801
+ status_code: http_response.status,
1802
+ body: http_response.env.response_body,
1803
+ raw_response: http_response
1804
+ ),
1805
+ "Unknown content type received"
1806
+ )
1807
+ end
1808
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
1809
+ raise(
1810
+ ::NoResponse::Models::Errors::APIStatusError.new(
1811
+ status_code: http_response.status,
1812
+ body: http_response.env.response_body,
1813
+ raw_response: http_response
1814
+ ),
1815
+ "API error occurred"
1816
+ )
1817
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
1818
+ raise(
1819
+ ::NoResponse::Models::Errors::APIStatusError.new(
1820
+ status_code: http_response.status,
1821
+ body: http_response.env.response_body,
1822
+ raw_response: http_response
1823
+ ),
1824
+ "API error occurred"
1825
+ )
1826
+ else
1827
+ raise(
1828
+ ::NoResponse::Models::Errors::APIStatusError.new(
1829
+ status_code: http_response.status,
1830
+ body: http_response.env.response_body,
1831
+ raw_response: http_response
1832
+ ),
1833
+ "Unknown status code received"
1834
+ )
1835
+
1836
+ end
1837
+ end
1838
+
1839
+ sig {
1840
+ params(
1841
+ account_id: ::String,
1842
+ limit: T.nilable(::Integer),
1843
+ cursor: T.nilable(::String),
1844
+ retries: T.nilable(Utils::RetryConfig),
1845
+ timeout_ms: T.nilable(Integer),
1846
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
1847
+ )
1848
+ .returns(Models::Operations::ListAccountOutcomesResponse)
1849
+ }
1850
+ def list_outcomes(account_id:, limit: nil, cursor: nil, retries: nil, timeout_ms: nil, http_headers: nil)
1851
+ # list_outcomes - List retained account feedback
1852
+ # List retained account reports, newest first. The page-level effective outcome id names the current report. Each receipt preserves the effective report and risk version from its original write. Page with the returned cursor.
1853
+ request = Models::Operations::ListAccountOutcomesRequest.new(
1854
+ account_id: account_id,
1855
+ limit: limit,
1856
+ cursor: cursor
1857
+ )
1858
+ url, params = @sdk_configuration.get_server_details
1859
+ base_url = Utils.template_url(url, params)
1860
+ url = Utils.generate_url(
1861
+ Models::Operations::ListAccountOutcomesRequest,
1862
+ base_url,
1863
+ "/v1/accounts/{account_id}/outcomes",
1864
+ request
1865
+ )
1866
+ headers = {}
1867
+ headers = T.cast(headers, T::Hash[String, String])
1868
+ query_params = Utils.get_query_params(Models::Operations::ListAccountOutcomesRequest, request, nil)
1869
+ headers["Accept"] = "application/json"
1870
+ headers["user-agent"] = @sdk_configuration.user_agent
1871
+ retries ||= @sdk_configuration.retry_config
1872
+ retries ||= Utils::RetryConfig.new(
1873
+ backoff: Utils::BackoffStrategy.new(
1874
+ exponent: 2.0,
1875
+ initial_interval: 500,
1876
+ max_elapsed_time: 30_000,
1877
+ max_interval: 8000
1878
+ ),
1879
+ retry_connection_errors: true,
1880
+ strategy: "backoff"
1881
+ )
1882
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
1883
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
1884
+
1885
+ security = @sdk_configuration.security_source&.call
1886
+
1887
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
1888
+ timeout ||= @sdk_configuration.timeout
1889
+
1890
+ connection = @sdk_configuration.client.dup
1891
+ connection.use(Utils::RetryMiddleware, retry_options)
1892
+
1893
+ hook_ctx = SDKHooks::HookContext.new(
1894
+ config: @sdk_configuration,
1895
+ base_url: base_url,
1896
+ oauth2_scopes: nil,
1897
+ operation_id: "listAccountOutcomes",
1898
+ security_source: @sdk_configuration.security_source
1899
+ )
1900
+
1901
+ error = T.let(nil, T.nilable(StandardError))
1902
+ http_response = T.let(nil, T.nilable(Faraday::Response))
1903
+
1904
+ begin
1905
+ http_response = T.must(connection).get(url) do |req|
1906
+ req.headers.merge!(headers)
1907
+ req.options.timeout = timeout unless timeout.nil?
1908
+ req.params = query_params
1909
+ Utils.configure_request_security(req, security)
1910
+ http_headers&.each do |key, value|
1911
+ req.headers[key.to_s] = value
1912
+ end
1913
+
1914
+ @sdk_configuration.hooks.before_request(
1915
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
1916
+ hook_ctx: hook_ctx
1917
+ ),
1918
+ request: req
1919
+ )
1920
+ end
1921
+
1922
+ rescue StandardError => e
1923
+ error = e
1924
+ ensure
1925
+ if http_response.nil? || Utils.error_status?(http_response.status)
1926
+ http_response = @sdk_configuration.hooks.after_error(
1927
+ error: error,
1928
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
1929
+ hook_ctx: hook_ctx
1930
+ ),
1931
+ response: http_response
1932
+ )
1933
+ else
1934
+ http_response = @sdk_configuration.hooks.after_success(
1935
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1936
+ hook_ctx: hook_ctx
1937
+ ),
1938
+ response: http_response
1939
+ )
1940
+ end
1941
+
1942
+ if http_response.nil?
1943
+ raise error if !error.nil?
1944
+ raise "no response"
1945
+ end
1946
+ end
1947
+
1948
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
1949
+ if Utils.match_status_code(http_response.status, ["200"])
1950
+ if Utils.match_content_type(content_type, "application/json")
1951
+ @sdk_configuration.hooks.after_success(
1952
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1953
+ hook_ctx: hook_ctx
1954
+ ),
1955
+ response: http_response
1956
+ )
1957
+ response_data = http_response.env.response_body
1958
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AccountOutcomePage)
1959
+ result = obj
1960
+ response = Models::Operations::ListAccountOutcomesResponse.new(
1961
+ result: result,
1962
+ headers: http_response.headers
1963
+ )
1964
+
1965
+ return response
1966
+ else
1967
+ raise(
1968
+ ::NoResponse::Models::Errors::APIStatusError.new(
1969
+ status_code: http_response.status,
1970
+ body: http_response.env.response_body,
1971
+ raw_response: http_response
1972
+ ),
1973
+ "Unknown content type received"
1974
+ )
1975
+ end
1976
+ elsif Utils.match_status_code(http_response.status, ["400"])
1977
+ if Utils.match_content_type(content_type, "application/problem+json")
1978
+ @sdk_configuration.hooks.after_success(
1979
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
1980
+ hook_ctx: hook_ctx
1981
+ ),
1982
+ response: http_response
1983
+ )
1984
+ response_data = http_response.env.response_body
1985
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
1986
+ raise obj
1987
+ else
1988
+ raise(
1989
+ ::NoResponse::Models::Errors::APIStatusError.new(
1990
+ status_code: http_response.status,
1991
+ body: http_response.env.response_body,
1992
+ raw_response: http_response
1993
+ ),
1994
+ "Unknown content type received"
1995
+ )
1996
+ end
1997
+ elsif Utils.match_status_code(http_response.status, ["401"])
1998
+ if Utils.match_content_type(content_type, "application/problem+json")
1999
+ @sdk_configuration.hooks.after_success(
2000
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2001
+ hook_ctx: hook_ctx
2002
+ ),
2003
+ response: http_response
2004
+ )
2005
+ response_data = http_response.env.response_body
2006
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2007
+ raise obj
2008
+ else
2009
+ raise(
2010
+ ::NoResponse::Models::Errors::APIStatusError.new(
2011
+ status_code: http_response.status,
2012
+ body: http_response.env.response_body,
2013
+ raw_response: http_response
2014
+ ),
2015
+ "Unknown content type received"
2016
+ )
2017
+ end
2018
+ elsif Utils.match_status_code(http_response.status, ["403"])
2019
+ if Utils.match_content_type(content_type, "application/problem+json")
2020
+ @sdk_configuration.hooks.after_success(
2021
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2022
+ hook_ctx: hook_ctx
2023
+ ),
2024
+ response: http_response
2025
+ )
2026
+ response_data = http_response.env.response_body
2027
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2028
+ raise obj
2029
+ else
2030
+ raise(
2031
+ ::NoResponse::Models::Errors::APIStatusError.new(
2032
+ status_code: http_response.status,
2033
+ body: http_response.env.response_body,
2034
+ raw_response: http_response
2035
+ ),
2036
+ "Unknown content type received"
2037
+ )
2038
+ end
2039
+ elsif Utils.match_status_code(http_response.status, ["404"])
2040
+ if Utils.match_content_type(content_type, "application/problem+json")
2041
+ @sdk_configuration.hooks.after_success(
2042
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2043
+ hook_ctx: hook_ctx
2044
+ ),
2045
+ response: http_response
2046
+ )
2047
+ response_data = http_response.env.response_body
2048
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2049
+ raise obj
2050
+ else
2051
+ raise(
2052
+ ::NoResponse::Models::Errors::APIStatusError.new(
2053
+ status_code: http_response.status,
2054
+ body: http_response.env.response_body,
2055
+ raw_response: http_response
2056
+ ),
2057
+ "Unknown content type received"
2058
+ )
2059
+ end
2060
+ elsif Utils.match_status_code(http_response.status, ["409"])
2061
+ if Utils.match_content_type(content_type, "application/problem+json")
2062
+ @sdk_configuration.hooks.after_success(
2063
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2064
+ hook_ctx: hook_ctx
2065
+ ),
2066
+ response: http_response
2067
+ )
2068
+ response_data = http_response.env.response_body
2069
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2070
+ raise obj
2071
+ else
2072
+ raise(
2073
+ ::NoResponse::Models::Errors::APIStatusError.new(
2074
+ status_code: http_response.status,
2075
+ body: http_response.env.response_body,
2076
+ raw_response: http_response
2077
+ ),
2078
+ "Unknown content type received"
2079
+ )
2080
+ end
2081
+ elsif Utils.match_status_code(http_response.status, ["429"])
2082
+ if Utils.match_content_type(content_type, "application/problem+json")
2083
+ @sdk_configuration.hooks.after_success(
2084
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2085
+ hook_ctx: hook_ctx
2086
+ ),
2087
+ response: http_response
2088
+ )
2089
+ response_data = http_response.env.response_body
2090
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2091
+ raise obj
2092
+ else
2093
+ raise(
2094
+ ::NoResponse::Models::Errors::APIStatusError.new(
2095
+ status_code: http_response.status,
2096
+ body: http_response.env.response_body,
2097
+ raw_response: http_response
2098
+ ),
2099
+ "Unknown content type received"
2100
+ )
2101
+ end
2102
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2103
+ raise(
2104
+ ::NoResponse::Models::Errors::APIStatusError.new(
2105
+ status_code: http_response.status,
2106
+ body: http_response.env.response_body,
2107
+ raw_response: http_response
2108
+ ),
2109
+ "API error occurred"
2110
+ )
2111
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2112
+ raise(
2113
+ ::NoResponse::Models::Errors::APIStatusError.new(
2114
+ status_code: http_response.status,
2115
+ body: http_response.env.response_body,
2116
+ raw_response: http_response
2117
+ ),
2118
+ "API error occurred"
2119
+ )
2120
+ else
2121
+ raise(
2122
+ ::NoResponse::Models::Errors::APIStatusError.new(
2123
+ status_code: http_response.status,
2124
+ body: http_response.env.response_body,
2125
+ raw_response: http_response
2126
+ ),
2127
+ "Unknown status code received"
2128
+ )
2129
+
2130
+ end
2131
+ end
2132
+
2133
+ sig {
2134
+ params(
2135
+ account_id: ::String,
2136
+ risk_version: ::Integer,
2137
+ retries: T.nilable(Utils::RetryConfig),
2138
+ timeout_ms: T.nilable(Integer),
2139
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2140
+ )
2141
+ .returns(Models::Operations::GetAccountDecisionResponse)
2142
+ }
2143
+ def retrieve_decision(account_id:, risk_version:, retries: nil, timeout_ms: nil, http_headers: nil)
2144
+ # retrieve_decision - Retrieve an exact historical account decision
2145
+ # Retrieve the account decision at one recorded risk version. The answer uses the original assessment and account-specific risk inputs. Earlier versions that were not captured return 404. The assessment version, policy version and account calculation version identify the decision.
2146
+ request = Models::Operations::GetAccountDecisionRequest.new(
2147
+ account_id: account_id,
2148
+ risk_version: risk_version
2149
+ )
2150
+ url, params = @sdk_configuration.get_server_details
2151
+ base_url = Utils.template_url(url, params)
2152
+ url = Utils.generate_url(
2153
+ Models::Operations::GetAccountDecisionRequest,
2154
+ base_url,
2155
+ "/v1/accounts/{account_id}/decisions/{risk_version}",
2156
+ request
2157
+ )
2158
+ headers = {}
2159
+ headers = T.cast(headers, T::Hash[String, String])
2160
+ headers["Accept"] = "application/json"
2161
+ headers["user-agent"] = @sdk_configuration.user_agent
2162
+ retries ||= @sdk_configuration.retry_config
2163
+ retries ||= Utils::RetryConfig.new(
2164
+ backoff: Utils::BackoffStrategy.new(
2165
+ exponent: 2.0,
2166
+ initial_interval: 500,
2167
+ max_elapsed_time: 30_000,
2168
+ max_interval: 8000
2169
+ ),
2170
+ retry_connection_errors: true,
2171
+ strategy: "backoff"
2172
+ )
2173
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2174
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2175
+
2176
+ security = @sdk_configuration.security_source&.call
2177
+
2178
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2179
+ timeout ||= @sdk_configuration.timeout
2180
+
2181
+ connection = @sdk_configuration.client.dup
2182
+ connection.use(Utils::RetryMiddleware, retry_options)
2183
+
2184
+ hook_ctx = SDKHooks::HookContext.new(
2185
+ config: @sdk_configuration,
2186
+ base_url: base_url,
2187
+ oauth2_scopes: nil,
2188
+ operation_id: "getAccountDecision",
2189
+ security_source: @sdk_configuration.security_source
2190
+ )
2191
+
2192
+ error = T.let(nil, T.nilable(StandardError))
2193
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2194
+
2195
+ begin
2196
+ http_response = T.must(connection).get(url) do |req|
2197
+ req.headers.merge!(headers)
2198
+ req.options.timeout = timeout unless timeout.nil?
2199
+ Utils.configure_request_security(req, security)
2200
+ http_headers&.each do |key, value|
2201
+ req.headers[key.to_s] = value
2202
+ end
2203
+
2204
+ @sdk_configuration.hooks.before_request(
2205
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2206
+ hook_ctx: hook_ctx
2207
+ ),
2208
+ request: req
2209
+ )
2210
+ end
2211
+
2212
+ rescue StandardError => e
2213
+ error = e
2214
+ ensure
2215
+ if http_response.nil? || Utils.error_status?(http_response.status)
2216
+ http_response = @sdk_configuration.hooks.after_error(
2217
+ error: error,
2218
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2219
+ hook_ctx: hook_ctx
2220
+ ),
2221
+ response: http_response
2222
+ )
2223
+ else
2224
+ http_response = @sdk_configuration.hooks.after_success(
2225
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2226
+ hook_ctx: hook_ctx
2227
+ ),
2228
+ response: http_response
2229
+ )
2230
+ end
2231
+
2232
+ if http_response.nil?
2233
+ raise error if !error.nil?
2234
+ raise "no response"
2235
+ end
2236
+ end
2237
+
2238
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2239
+ if Utils.match_status_code(http_response.status, ["200"])
2240
+ if Utils.match_content_type(content_type, "application/json")
2241
+ @sdk_configuration.hooks.after_success(
2242
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2243
+ hook_ctx: hook_ctx
2244
+ ),
2245
+ response: http_response
2246
+ )
2247
+ response_data = http_response.env.response_body
2248
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AccountDecisionSnapshot)
2249
+ result = obj
2250
+ response = Models::Operations::GetAccountDecisionResponse.new(
2251
+ result: result,
2252
+ headers: http_response.headers
2253
+ )
2254
+
2255
+ return response
2256
+ else
2257
+ raise(
2258
+ ::NoResponse::Models::Errors::APIStatusError.new(
2259
+ status_code: http_response.status,
2260
+ body: http_response.env.response_body,
2261
+ raw_response: http_response
2262
+ ),
2263
+ "Unknown content type received"
2264
+ )
2265
+ end
2266
+ elsif Utils.match_status_code(http_response.status, ["400"])
2267
+ if Utils.match_content_type(content_type, "application/problem+json")
2268
+ @sdk_configuration.hooks.after_success(
2269
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2270
+ hook_ctx: hook_ctx
2271
+ ),
2272
+ response: http_response
2273
+ )
2274
+ response_data = http_response.env.response_body
2275
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2276
+ raise obj
2277
+ else
2278
+ raise(
2279
+ ::NoResponse::Models::Errors::APIStatusError.new(
2280
+ status_code: http_response.status,
2281
+ body: http_response.env.response_body,
2282
+ raw_response: http_response
2283
+ ),
2284
+ "Unknown content type received"
2285
+ )
2286
+ end
2287
+ elsif Utils.match_status_code(http_response.status, ["401"])
2288
+ if Utils.match_content_type(content_type, "application/problem+json")
2289
+ @sdk_configuration.hooks.after_success(
2290
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2291
+ hook_ctx: hook_ctx
2292
+ ),
2293
+ response: http_response
2294
+ )
2295
+ response_data = http_response.env.response_body
2296
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2297
+ raise obj
2298
+ else
2299
+ raise(
2300
+ ::NoResponse::Models::Errors::APIStatusError.new(
2301
+ status_code: http_response.status,
2302
+ body: http_response.env.response_body,
2303
+ raw_response: http_response
2304
+ ),
2305
+ "Unknown content type received"
2306
+ )
2307
+ end
2308
+ elsif Utils.match_status_code(http_response.status, ["403"])
2309
+ if Utils.match_content_type(content_type, "application/problem+json")
2310
+ @sdk_configuration.hooks.after_success(
2311
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2312
+ hook_ctx: hook_ctx
2313
+ ),
2314
+ response: http_response
2315
+ )
2316
+ response_data = http_response.env.response_body
2317
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2318
+ raise obj
2319
+ else
2320
+ raise(
2321
+ ::NoResponse::Models::Errors::APIStatusError.new(
2322
+ status_code: http_response.status,
2323
+ body: http_response.env.response_body,
2324
+ raw_response: http_response
2325
+ ),
2326
+ "Unknown content type received"
2327
+ )
2328
+ end
2329
+ elsif Utils.match_status_code(http_response.status, ["404"])
2330
+ if Utils.match_content_type(content_type, "application/problem+json")
2331
+ @sdk_configuration.hooks.after_success(
2332
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2333
+ hook_ctx: hook_ctx
2334
+ ),
2335
+ response: http_response
2336
+ )
2337
+ response_data = http_response.env.response_body
2338
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2339
+ raise obj
2340
+ else
2341
+ raise(
2342
+ ::NoResponse::Models::Errors::APIStatusError.new(
2343
+ status_code: http_response.status,
2344
+ body: http_response.env.response_body,
2345
+ raw_response: http_response
2346
+ ),
2347
+ "Unknown content type received"
2348
+ )
2349
+ end
2350
+ elsif Utils.match_status_code(http_response.status, ["409"])
2351
+ if Utils.match_content_type(content_type, "application/problem+json")
2352
+ @sdk_configuration.hooks.after_success(
2353
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2354
+ hook_ctx: hook_ctx
2355
+ ),
2356
+ response: http_response
2357
+ )
2358
+ response_data = http_response.env.response_body
2359
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2360
+ raise obj
2361
+ else
2362
+ raise(
2363
+ ::NoResponse::Models::Errors::APIStatusError.new(
2364
+ status_code: http_response.status,
2365
+ body: http_response.env.response_body,
2366
+ raw_response: http_response
2367
+ ),
2368
+ "Unknown content type received"
2369
+ )
2370
+ end
2371
+ elsif Utils.match_status_code(http_response.status, ["429"])
2372
+ if Utils.match_content_type(content_type, "application/problem+json")
2373
+ @sdk_configuration.hooks.after_success(
2374
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2375
+ hook_ctx: hook_ctx
2376
+ ),
2377
+ response: http_response
2378
+ )
2379
+ response_data = http_response.env.response_body
2380
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2381
+ raise obj
2382
+ else
2383
+ raise(
2384
+ ::NoResponse::Models::Errors::APIStatusError.new(
2385
+ status_code: http_response.status,
2386
+ body: http_response.env.response_body,
2387
+ raw_response: http_response
2388
+ ),
2389
+ "Unknown content type received"
2390
+ )
2391
+ end
2392
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2393
+ raise(
2394
+ ::NoResponse::Models::Errors::APIStatusError.new(
2395
+ status_code: http_response.status,
2396
+ body: http_response.env.response_body,
2397
+ raw_response: http_response
2398
+ ),
2399
+ "API error occurred"
2400
+ )
2401
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2402
+ raise(
2403
+ ::NoResponse::Models::Errors::APIStatusError.new(
2404
+ status_code: http_response.status,
2405
+ body: http_response.env.response_body,
2406
+ raw_response: http_response
2407
+ ),
2408
+ "API error occurred"
2409
+ )
2410
+ else
2411
+ raise(
2412
+ ::NoResponse::Models::Errors::APIStatusError.new(
2413
+ status_code: http_response.status,
2414
+ body: http_response.env.response_body,
2415
+ raw_response: http_response
2416
+ ),
2417
+ "Unknown status code received"
2418
+ )
2419
+
2420
+ end
2421
+ end
2422
+
2423
+ sig {
2424
+ params(
2425
+ body: Models::Shared::CredentialRequest,
2426
+ account_id: ::String,
2427
+ retries: T.nilable(Utils::RetryConfig),
2428
+ timeout_ms: T.nilable(Integer),
2429
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2430
+ )
2431
+ .returns(Models::Operations::AssociateCredentialResponse)
2432
+ }
2433
+ def associate_credential(body:, account_id:, retries: nil, timeout_ms: nil, http_headers: nil)
2434
+ # associate_credential - Associate a customer-issued API key
2435
+ # Associate the SHA-256 of a high-entropy key issued by your service. Send the hash instead of the key. Repeating a hash returns its original association, including its retirement state. A hash associated with another account returns a conflict.
2436
+ request = Models::Operations::AssociateCredentialRequest.new(
2437
+ account_id: account_id,
2438
+ body: body
2439
+ )
2440
+ url, params = @sdk_configuration.get_server_details
2441
+ base_url = Utils.template_url(url, params)
2442
+ url = Utils.generate_url(
2443
+ Models::Operations::AssociateCredentialRequest,
2444
+ base_url,
2445
+ "/v1/accounts/{account_id}/credentials",
2446
+ request
2447
+ )
2448
+ headers = {}
2449
+ headers = T.cast(headers, T::Hash[String, String])
2450
+ req_content_type, data, form = Utils.serialize_request_body(request, false, false, :body, :json)
2451
+ headers["content-type"] = req_content_type
2452
+ raise StandardError, "request body is required" if data.nil? && form.nil?
2453
+
2454
+ if form && !form.empty?
2455
+ body = Utils.encode_form(form)
2456
+ elsif Utils.match_content_type(req_content_type, "application/x-www-form-urlencoded")
2457
+ body = URI.encode_www_form(T.cast(data, T::Hash[Symbol, Object]))
2458
+ else
2459
+ body = data
2460
+ end
2461
+
2462
+ headers["Accept"] = "application/json"
2463
+ headers["user-agent"] = @sdk_configuration.user_agent
2464
+ retries ||= @sdk_configuration.retry_config
2465
+ retries ||= Utils::RetryConfig.new(
2466
+ backoff: Utils::BackoffStrategy.new(
2467
+ exponent: 2.0,
2468
+ initial_interval: 500,
2469
+ max_elapsed_time: 30_000,
2470
+ max_interval: 8000
2471
+ ),
2472
+ retry_connection_errors: true,
2473
+ strategy: "backoff"
2474
+ )
2475
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2476
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2477
+
2478
+ security = @sdk_configuration.security_source&.call
2479
+
2480
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2481
+ timeout ||= @sdk_configuration.timeout
2482
+
2483
+ connection = @sdk_configuration.client.dup
2484
+ connection.use(Utils::RetryMiddleware, retry_options)
2485
+
2486
+ hook_ctx = SDKHooks::HookContext.new(
2487
+ config: @sdk_configuration,
2488
+ base_url: base_url,
2489
+ oauth2_scopes: nil,
2490
+ operation_id: "associateCredential",
2491
+ security_source: @sdk_configuration.security_source
2492
+ )
2493
+
2494
+ error = T.let(nil, T.nilable(StandardError))
2495
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2496
+
2497
+ begin
2498
+ http_response = T.must(connection).post(url) do |req|
2499
+ req.body = body
2500
+ req.headers.merge!(headers)
2501
+ req.options.timeout = timeout unless timeout.nil?
2502
+ Utils.configure_request_security(req, security)
2503
+ http_headers&.each do |key, value|
2504
+ req.headers[key.to_s] = value
2505
+ end
2506
+
2507
+ @sdk_configuration.hooks.before_request(
2508
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2509
+ hook_ctx: hook_ctx
2510
+ ),
2511
+ request: req
2512
+ )
2513
+ end
2514
+
2515
+ rescue StandardError => e
2516
+ error = e
2517
+ ensure
2518
+ if http_response.nil? || Utils.error_status?(http_response.status)
2519
+ http_response = @sdk_configuration.hooks.after_error(
2520
+ error: error,
2521
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2522
+ hook_ctx: hook_ctx
2523
+ ),
2524
+ response: http_response
2525
+ )
2526
+ else
2527
+ http_response = @sdk_configuration.hooks.after_success(
2528
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2529
+ hook_ctx: hook_ctx
2530
+ ),
2531
+ response: http_response
2532
+ )
2533
+ end
2534
+
2535
+ if http_response.nil?
2536
+ raise error if !error.nil?
2537
+ raise "no response"
2538
+ end
2539
+ end
2540
+
2541
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2542
+ if Utils.match_status_code(http_response.status, ["200", "201"])
2543
+ if Utils.match_content_type(content_type, "application/json")
2544
+ @sdk_configuration.hooks.after_success(
2545
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2546
+ hook_ctx: hook_ctx
2547
+ ),
2548
+ response: http_response
2549
+ )
2550
+ response_data = http_response.env.response_body
2551
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::CredentialAssociation)
2552
+ result = obj
2553
+ response = Models::Operations::AssociateCredentialResponse.new(
2554
+ result: result,
2555
+ headers: http_response.headers
2556
+ )
2557
+
2558
+ return response
2559
+ else
2560
+ raise(
2561
+ ::NoResponse::Models::Errors::APIStatusError.new(
2562
+ status_code: http_response.status,
2563
+ body: http_response.env.response_body,
2564
+ raw_response: http_response
2565
+ ),
2566
+ "Unknown content type received"
2567
+ )
2568
+ end
2569
+ elsif Utils.match_status_code(http_response.status, ["400"])
2570
+ if Utils.match_content_type(content_type, "application/problem+json")
2571
+ @sdk_configuration.hooks.after_success(
2572
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2573
+ hook_ctx: hook_ctx
2574
+ ),
2575
+ response: http_response
2576
+ )
2577
+ response_data = http_response.env.response_body
2578
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2579
+ raise obj
2580
+ else
2581
+ raise(
2582
+ ::NoResponse::Models::Errors::APIStatusError.new(
2583
+ status_code: http_response.status,
2584
+ body: http_response.env.response_body,
2585
+ raw_response: http_response
2586
+ ),
2587
+ "Unknown content type received"
2588
+ )
2589
+ end
2590
+ elsif Utils.match_status_code(http_response.status, ["401"])
2591
+ if Utils.match_content_type(content_type, "application/problem+json")
2592
+ @sdk_configuration.hooks.after_success(
2593
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2594
+ hook_ctx: hook_ctx
2595
+ ),
2596
+ response: http_response
2597
+ )
2598
+ response_data = http_response.env.response_body
2599
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2600
+ raise obj
2601
+ else
2602
+ raise(
2603
+ ::NoResponse::Models::Errors::APIStatusError.new(
2604
+ status_code: http_response.status,
2605
+ body: http_response.env.response_body,
2606
+ raw_response: http_response
2607
+ ),
2608
+ "Unknown content type received"
2609
+ )
2610
+ end
2611
+ elsif Utils.match_status_code(http_response.status, ["403"])
2612
+ if Utils.match_content_type(content_type, "application/problem+json")
2613
+ @sdk_configuration.hooks.after_success(
2614
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2615
+ hook_ctx: hook_ctx
2616
+ ),
2617
+ response: http_response
2618
+ )
2619
+ response_data = http_response.env.response_body
2620
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2621
+ raise obj
2622
+ else
2623
+ raise(
2624
+ ::NoResponse::Models::Errors::APIStatusError.new(
2625
+ status_code: http_response.status,
2626
+ body: http_response.env.response_body,
2627
+ raw_response: http_response
2628
+ ),
2629
+ "Unknown content type received"
2630
+ )
2631
+ end
2632
+ elsif Utils.match_status_code(http_response.status, ["404"])
2633
+ if Utils.match_content_type(content_type, "application/problem+json")
2634
+ @sdk_configuration.hooks.after_success(
2635
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2636
+ hook_ctx: hook_ctx
2637
+ ),
2638
+ response: http_response
2639
+ )
2640
+ response_data = http_response.env.response_body
2641
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2642
+ raise obj
2643
+ else
2644
+ raise(
2645
+ ::NoResponse::Models::Errors::APIStatusError.new(
2646
+ status_code: http_response.status,
2647
+ body: http_response.env.response_body,
2648
+ raw_response: http_response
2649
+ ),
2650
+ "Unknown content type received"
2651
+ )
2652
+ end
2653
+ elsif Utils.match_status_code(http_response.status, ["409"])
2654
+ if Utils.match_content_type(content_type, "application/problem+json")
2655
+ @sdk_configuration.hooks.after_success(
2656
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2657
+ hook_ctx: hook_ctx
2658
+ ),
2659
+ response: http_response
2660
+ )
2661
+ response_data = http_response.env.response_body
2662
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2663
+ raise obj
2664
+ else
2665
+ raise(
2666
+ ::NoResponse::Models::Errors::APIStatusError.new(
2667
+ status_code: http_response.status,
2668
+ body: http_response.env.response_body,
2669
+ raw_response: http_response
2670
+ ),
2671
+ "Unknown content type received"
2672
+ )
2673
+ end
2674
+ elsif Utils.match_status_code(http_response.status, ["429"])
2675
+ if Utils.match_content_type(content_type, "application/problem+json")
2676
+ @sdk_configuration.hooks.after_success(
2677
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2678
+ hook_ctx: hook_ctx
2679
+ ),
2680
+ response: http_response
2681
+ )
2682
+ response_data = http_response.env.response_body
2683
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2684
+ raise obj
2685
+ else
2686
+ raise(
2687
+ ::NoResponse::Models::Errors::APIStatusError.new(
2688
+ status_code: http_response.status,
2689
+ body: http_response.env.response_body,
2690
+ raw_response: http_response
2691
+ ),
2692
+ "Unknown content type received"
2693
+ )
2694
+ end
2695
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2696
+ raise(
2697
+ ::NoResponse::Models::Errors::APIStatusError.new(
2698
+ status_code: http_response.status,
2699
+ body: http_response.env.response_body,
2700
+ raw_response: http_response
2701
+ ),
2702
+ "API error occurred"
2703
+ )
2704
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2705
+ raise(
2706
+ ::NoResponse::Models::Errors::APIStatusError.new(
2707
+ status_code: http_response.status,
2708
+ body: http_response.env.response_body,
2709
+ raw_response: http_response
2710
+ ),
2711
+ "API error occurred"
2712
+ )
2713
+ else
2714
+ raise(
2715
+ ::NoResponse::Models::Errors::APIStatusError.new(
2716
+ status_code: http_response.status,
2717
+ body: http_response.env.response_body,
2718
+ raw_response: http_response
2719
+ ),
2720
+ "Unknown status code received"
2721
+ )
2722
+
2723
+ end
2724
+ end
2725
+
2726
+ sig {
2727
+ params(
2728
+ account_id: ::String,
2729
+ limit: T.nilable(::Integer),
2730
+ cursor: T.nilable(::String),
2731
+ retries: T.nilable(Utils::RetryConfig),
2732
+ timeout_ms: T.nilable(Integer),
2733
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
2734
+ )
2735
+ .returns(Models::Operations::ListAccountCredentialsResponse)
2736
+ }
2737
+ def list_credentials(account_id:, limit: nil, cursor: nil, retries: nil, timeout_ms: nil, http_headers: nil)
2738
+ # list_credentials - List issued credential associations
2739
+ # Retained credential associations, ordered by id. Page with the authenticated cursor. Associations are removed on account erasure.
2740
+ request = Models::Operations::ListAccountCredentialsRequest.new(
2741
+ account_id: account_id,
2742
+ limit: limit,
2743
+ cursor: cursor
2744
+ )
2745
+ url, params = @sdk_configuration.get_server_details
2746
+ base_url = Utils.template_url(url, params)
2747
+ url = Utils.generate_url(
2748
+ Models::Operations::ListAccountCredentialsRequest,
2749
+ base_url,
2750
+ "/v1/accounts/{account_id}/credentials",
2751
+ request
2752
+ )
2753
+ headers = {}
2754
+ headers = T.cast(headers, T::Hash[String, String])
2755
+ query_params = Utils.get_query_params(Models::Operations::ListAccountCredentialsRequest, request, nil)
2756
+ headers["Accept"] = "application/json"
2757
+ headers["user-agent"] = @sdk_configuration.user_agent
2758
+ retries ||= @sdk_configuration.retry_config
2759
+ retries ||= Utils::RetryConfig.new(
2760
+ backoff: Utils::BackoffStrategy.new(
2761
+ exponent: 2.0,
2762
+ initial_interval: 500,
2763
+ max_elapsed_time: 30_000,
2764
+ max_interval: 8000
2765
+ ),
2766
+ retry_connection_errors: true,
2767
+ strategy: "backoff"
2768
+ )
2769
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
2770
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
2771
+
2772
+ security = @sdk_configuration.security_source&.call
2773
+
2774
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
2775
+ timeout ||= @sdk_configuration.timeout
2776
+
2777
+ connection = @sdk_configuration.client.dup
2778
+ connection.use(Utils::RetryMiddleware, retry_options)
2779
+
2780
+ hook_ctx = SDKHooks::HookContext.new(
2781
+ config: @sdk_configuration,
2782
+ base_url: base_url,
2783
+ oauth2_scopes: nil,
2784
+ operation_id: "listAccountCredentials",
2785
+ security_source: @sdk_configuration.security_source
2786
+ )
2787
+
2788
+ error = T.let(nil, T.nilable(StandardError))
2789
+ http_response = T.let(nil, T.nilable(Faraday::Response))
2790
+
2791
+ begin
2792
+ http_response = T.must(connection).get(url) do |req|
2793
+ req.headers.merge!(headers)
2794
+ req.options.timeout = timeout unless timeout.nil?
2795
+ req.params = query_params
2796
+ Utils.configure_request_security(req, security)
2797
+ http_headers&.each do |key, value|
2798
+ req.headers[key.to_s] = value
2799
+ end
2800
+
2801
+ @sdk_configuration.hooks.before_request(
2802
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
2803
+ hook_ctx: hook_ctx
2804
+ ),
2805
+ request: req
2806
+ )
2807
+ end
2808
+
2809
+ rescue StandardError => e
2810
+ error = e
2811
+ ensure
2812
+ if http_response.nil? || Utils.error_status?(http_response.status)
2813
+ http_response = @sdk_configuration.hooks.after_error(
2814
+ error: error,
2815
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
2816
+ hook_ctx: hook_ctx
2817
+ ),
2818
+ response: http_response
2819
+ )
2820
+ else
2821
+ http_response = @sdk_configuration.hooks.after_success(
2822
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2823
+ hook_ctx: hook_ctx
2824
+ ),
2825
+ response: http_response
2826
+ )
2827
+ end
2828
+
2829
+ if http_response.nil?
2830
+ raise error if !error.nil?
2831
+ raise "no response"
2832
+ end
2833
+ end
2834
+
2835
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
2836
+ if Utils.match_status_code(http_response.status, ["200"])
2837
+ if Utils.match_content_type(content_type, "application/json")
2838
+ @sdk_configuration.hooks.after_success(
2839
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2840
+ hook_ctx: hook_ctx
2841
+ ),
2842
+ response: http_response
2843
+ )
2844
+ response_data = http_response.env.response_body
2845
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::CredentialPage)
2846
+ result = obj
2847
+ response = Models::Operations::ListAccountCredentialsResponse.new(
2848
+ result: result,
2849
+ headers: http_response.headers
2850
+ )
2851
+
2852
+ return response
2853
+ else
2854
+ raise(
2855
+ ::NoResponse::Models::Errors::APIStatusError.new(
2856
+ status_code: http_response.status,
2857
+ body: http_response.env.response_body,
2858
+ raw_response: http_response
2859
+ ),
2860
+ "Unknown content type received"
2861
+ )
2862
+ end
2863
+ elsif Utils.match_status_code(http_response.status, ["400"])
2864
+ if Utils.match_content_type(content_type, "application/problem+json")
2865
+ @sdk_configuration.hooks.after_success(
2866
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2867
+ hook_ctx: hook_ctx
2868
+ ),
2869
+ response: http_response
2870
+ )
2871
+ response_data = http_response.env.response_body
2872
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
2873
+ raise obj
2874
+ else
2875
+ raise(
2876
+ ::NoResponse::Models::Errors::APIStatusError.new(
2877
+ status_code: http_response.status,
2878
+ body: http_response.env.response_body,
2879
+ raw_response: http_response
2880
+ ),
2881
+ "Unknown content type received"
2882
+ )
2883
+ end
2884
+ elsif Utils.match_status_code(http_response.status, ["401"])
2885
+ if Utils.match_content_type(content_type, "application/problem+json")
2886
+ @sdk_configuration.hooks.after_success(
2887
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2888
+ hook_ctx: hook_ctx
2889
+ ),
2890
+ response: http_response
2891
+ )
2892
+ response_data = http_response.env.response_body
2893
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
2894
+ raise obj
2895
+ else
2896
+ raise(
2897
+ ::NoResponse::Models::Errors::APIStatusError.new(
2898
+ status_code: http_response.status,
2899
+ body: http_response.env.response_body,
2900
+ raw_response: http_response
2901
+ ),
2902
+ "Unknown content type received"
2903
+ )
2904
+ end
2905
+ elsif Utils.match_status_code(http_response.status, ["403"])
2906
+ if Utils.match_content_type(content_type, "application/problem+json")
2907
+ @sdk_configuration.hooks.after_success(
2908
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2909
+ hook_ctx: hook_ctx
2910
+ ),
2911
+ response: http_response
2912
+ )
2913
+ response_data = http_response.env.response_body
2914
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
2915
+ raise obj
2916
+ else
2917
+ raise(
2918
+ ::NoResponse::Models::Errors::APIStatusError.new(
2919
+ status_code: http_response.status,
2920
+ body: http_response.env.response_body,
2921
+ raw_response: http_response
2922
+ ),
2923
+ "Unknown content type received"
2924
+ )
2925
+ end
2926
+ elsif Utils.match_status_code(http_response.status, ["404"])
2927
+ if Utils.match_content_type(content_type, "application/problem+json")
2928
+ @sdk_configuration.hooks.after_success(
2929
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2930
+ hook_ctx: hook_ctx
2931
+ ),
2932
+ response: http_response
2933
+ )
2934
+ response_data = http_response.env.response_body
2935
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
2936
+ raise obj
2937
+ else
2938
+ raise(
2939
+ ::NoResponse::Models::Errors::APIStatusError.new(
2940
+ status_code: http_response.status,
2941
+ body: http_response.env.response_body,
2942
+ raw_response: http_response
2943
+ ),
2944
+ "Unknown content type received"
2945
+ )
2946
+ end
2947
+ elsif Utils.match_status_code(http_response.status, ["409"])
2948
+ if Utils.match_content_type(content_type, "application/problem+json")
2949
+ @sdk_configuration.hooks.after_success(
2950
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2951
+ hook_ctx: hook_ctx
2952
+ ),
2953
+ response: http_response
2954
+ )
2955
+ response_data = http_response.env.response_body
2956
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
2957
+ raise obj
2958
+ else
2959
+ raise(
2960
+ ::NoResponse::Models::Errors::APIStatusError.new(
2961
+ status_code: http_response.status,
2962
+ body: http_response.env.response_body,
2963
+ raw_response: http_response
2964
+ ),
2965
+ "Unknown content type received"
2966
+ )
2967
+ end
2968
+ elsif Utils.match_status_code(http_response.status, ["429"])
2969
+ if Utils.match_content_type(content_type, "application/problem+json")
2970
+ @sdk_configuration.hooks.after_success(
2971
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
2972
+ hook_ctx: hook_ctx
2973
+ ),
2974
+ response: http_response
2975
+ )
2976
+ response_data = http_response.env.response_body
2977
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
2978
+ raise obj
2979
+ else
2980
+ raise(
2981
+ ::NoResponse::Models::Errors::APIStatusError.new(
2982
+ status_code: http_response.status,
2983
+ body: http_response.env.response_body,
2984
+ raw_response: http_response
2985
+ ),
2986
+ "Unknown content type received"
2987
+ )
2988
+ end
2989
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
2990
+ raise(
2991
+ ::NoResponse::Models::Errors::APIStatusError.new(
2992
+ status_code: http_response.status,
2993
+ body: http_response.env.response_body,
2994
+ raw_response: http_response
2995
+ ),
2996
+ "API error occurred"
2997
+ )
2998
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
2999
+ raise(
3000
+ ::NoResponse::Models::Errors::APIStatusError.new(
3001
+ status_code: http_response.status,
3002
+ body: http_response.env.response_body,
3003
+ raw_response: http_response
3004
+ ),
3005
+ "API error occurred"
3006
+ )
3007
+ else
3008
+ raise(
3009
+ ::NoResponse::Models::Errors::APIStatusError.new(
3010
+ status_code: http_response.status,
3011
+ body: http_response.env.response_body,
3012
+ raw_response: http_response
3013
+ ),
3014
+ "Unknown status code received"
3015
+ )
3016
+
3017
+ end
3018
+ end
3019
+
3020
+ sig {
3021
+ params(
3022
+ account_id: ::String,
3023
+ credential_id: ::String,
3024
+ retries: T.nilable(Utils::RetryConfig),
3025
+ timeout_ms: T.nilable(Integer),
3026
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
3027
+ )
3028
+ .returns(Models::Operations::RetireAccountCredentialResponse)
3029
+ }
3030
+ def retire_credential(account_id:, credential_id:, retries: nil, timeout_ms: nil, http_headers: nil)
3031
+ # retire_credential - Retire an issued credential association
3032
+ # Mark this association retired, idempotently. This does not revoke the actual key. Requires delete scope.
3033
+ request = Models::Operations::RetireAccountCredentialRequest.new(
3034
+ account_id: account_id,
3035
+ credential_id: credential_id
3036
+ )
3037
+ url, params = @sdk_configuration.get_server_details
3038
+ base_url = Utils.template_url(url, params)
3039
+ url = Utils.generate_url(
3040
+ Models::Operations::RetireAccountCredentialRequest,
3041
+ base_url,
3042
+ "/v1/accounts/{account_id}/credentials/{credential_id}",
3043
+ request
3044
+ )
3045
+ headers = {}
3046
+ headers = T.cast(headers, T::Hash[String, String])
3047
+ headers["Accept"] = "application/json"
3048
+ headers["user-agent"] = @sdk_configuration.user_agent
3049
+ retries ||= @sdk_configuration.retry_config
3050
+ retries ||= Utils::RetryConfig.new(
3051
+ backoff: Utils::BackoffStrategy.new(
3052
+ exponent: 2.0,
3053
+ initial_interval: 500,
3054
+ max_elapsed_time: 30_000,
3055
+ max_interval: 8000
3056
+ ),
3057
+ retry_connection_errors: true,
3058
+ strategy: "backoff"
3059
+ )
3060
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
3061
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
3062
+
3063
+ security = @sdk_configuration.security_source&.call
3064
+
3065
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
3066
+ timeout ||= @sdk_configuration.timeout
3067
+
3068
+ connection = @sdk_configuration.client.dup
3069
+ connection.use(Utils::RetryMiddleware, retry_options)
3070
+
3071
+ hook_ctx = SDKHooks::HookContext.new(
3072
+ config: @sdk_configuration,
3073
+ base_url: base_url,
3074
+ oauth2_scopes: nil,
3075
+ operation_id: "retireAccountCredential",
3076
+ security_source: @sdk_configuration.security_source
3077
+ )
3078
+
3079
+ error = T.let(nil, T.nilable(StandardError))
3080
+ http_response = T.let(nil, T.nilable(Faraday::Response))
3081
+
3082
+ begin
3083
+ http_response = T.must(connection).delete(url) do |req|
3084
+ req.headers.merge!(headers)
3085
+ req.options.timeout = timeout unless timeout.nil?
3086
+ Utils.configure_request_security(req, security)
3087
+ http_headers&.each do |key, value|
3088
+ req.headers[key.to_s] = value
3089
+ end
3090
+
3091
+ @sdk_configuration.hooks.before_request(
3092
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
3093
+ hook_ctx: hook_ctx
3094
+ ),
3095
+ request: req
3096
+ )
3097
+ end
3098
+
3099
+ rescue StandardError => e
3100
+ error = e
3101
+ ensure
3102
+ if http_response.nil? || Utils.error_status?(http_response.status)
3103
+ http_response = @sdk_configuration.hooks.after_error(
3104
+ error: error,
3105
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
3106
+ hook_ctx: hook_ctx
3107
+ ),
3108
+ response: http_response
3109
+ )
3110
+ else
3111
+ http_response = @sdk_configuration.hooks.after_success(
3112
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3113
+ hook_ctx: hook_ctx
3114
+ ),
3115
+ response: http_response
3116
+ )
3117
+ end
3118
+
3119
+ if http_response.nil?
3120
+ raise error if !error.nil?
3121
+ raise "no response"
3122
+ end
3123
+ end
3124
+
3125
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
3126
+ if Utils.match_status_code(http_response.status, ["200"])
3127
+ if Utils.match_content_type(content_type, "application/json")
3128
+ @sdk_configuration.hooks.after_success(
3129
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3130
+ hook_ctx: hook_ctx
3131
+ ),
3132
+ response: http_response
3133
+ )
3134
+ response_data = http_response.env.response_body
3135
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::CredentialAssociation)
3136
+ result = obj
3137
+ response = Models::Operations::RetireAccountCredentialResponse.new(
3138
+ result: result,
3139
+ headers: http_response.headers
3140
+ )
3141
+
3142
+ return response
3143
+ else
3144
+ raise(
3145
+ ::NoResponse::Models::Errors::APIStatusError.new(
3146
+ status_code: http_response.status,
3147
+ body: http_response.env.response_body,
3148
+ raw_response: http_response
3149
+ ),
3150
+ "Unknown content type received"
3151
+ )
3152
+ end
3153
+ elsif Utils.match_status_code(http_response.status, ["400"])
3154
+ if Utils.match_content_type(content_type, "application/problem+json")
3155
+ @sdk_configuration.hooks.after_success(
3156
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3157
+ hook_ctx: hook_ctx
3158
+ ),
3159
+ response: http_response
3160
+ )
3161
+ response_data = http_response.env.response_body
3162
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
3163
+ raise obj
3164
+ else
3165
+ raise(
3166
+ ::NoResponse::Models::Errors::APIStatusError.new(
3167
+ status_code: http_response.status,
3168
+ body: http_response.env.response_body,
3169
+ raw_response: http_response
3170
+ ),
3171
+ "Unknown content type received"
3172
+ )
3173
+ end
3174
+ elsif Utils.match_status_code(http_response.status, ["401"])
3175
+ if Utils.match_content_type(content_type, "application/problem+json")
3176
+ @sdk_configuration.hooks.after_success(
3177
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3178
+ hook_ctx: hook_ctx
3179
+ ),
3180
+ response: http_response
3181
+ )
3182
+ response_data = http_response.env.response_body
3183
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
3184
+ raise obj
3185
+ else
3186
+ raise(
3187
+ ::NoResponse::Models::Errors::APIStatusError.new(
3188
+ status_code: http_response.status,
3189
+ body: http_response.env.response_body,
3190
+ raw_response: http_response
3191
+ ),
3192
+ "Unknown content type received"
3193
+ )
3194
+ end
3195
+ elsif Utils.match_status_code(http_response.status, ["403"])
3196
+ if Utils.match_content_type(content_type, "application/problem+json")
3197
+ @sdk_configuration.hooks.after_success(
3198
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3199
+ hook_ctx: hook_ctx
3200
+ ),
3201
+ response: http_response
3202
+ )
3203
+ response_data = http_response.env.response_body
3204
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
3205
+ raise obj
3206
+ else
3207
+ raise(
3208
+ ::NoResponse::Models::Errors::APIStatusError.new(
3209
+ status_code: http_response.status,
3210
+ body: http_response.env.response_body,
3211
+ raw_response: http_response
3212
+ ),
3213
+ "Unknown content type received"
3214
+ )
3215
+ end
3216
+ elsif Utils.match_status_code(http_response.status, ["404"])
3217
+ if Utils.match_content_type(content_type, "application/problem+json")
3218
+ @sdk_configuration.hooks.after_success(
3219
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3220
+ hook_ctx: hook_ctx
3221
+ ),
3222
+ response: http_response
3223
+ )
3224
+ response_data = http_response.env.response_body
3225
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
3226
+ raise obj
3227
+ else
3228
+ raise(
3229
+ ::NoResponse::Models::Errors::APIStatusError.new(
3230
+ status_code: http_response.status,
3231
+ body: http_response.env.response_body,
3232
+ raw_response: http_response
3233
+ ),
3234
+ "Unknown content type received"
3235
+ )
3236
+ end
3237
+ elsif Utils.match_status_code(http_response.status, ["409"])
3238
+ if Utils.match_content_type(content_type, "application/problem+json")
3239
+ @sdk_configuration.hooks.after_success(
3240
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3241
+ hook_ctx: hook_ctx
3242
+ ),
3243
+ response: http_response
3244
+ )
3245
+ response_data = http_response.env.response_body
3246
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
3247
+ raise obj
3248
+ else
3249
+ raise(
3250
+ ::NoResponse::Models::Errors::APIStatusError.new(
3251
+ status_code: http_response.status,
3252
+ body: http_response.env.response_body,
3253
+ raw_response: http_response
3254
+ ),
3255
+ "Unknown content type received"
3256
+ )
3257
+ end
3258
+ elsif Utils.match_status_code(http_response.status, ["429"])
3259
+ if Utils.match_content_type(content_type, "application/problem+json")
3260
+ @sdk_configuration.hooks.after_success(
3261
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3262
+ hook_ctx: hook_ctx
3263
+ ),
3264
+ response: http_response
3265
+ )
3266
+ response_data = http_response.env.response_body
3267
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
3268
+ raise obj
3269
+ else
3270
+ raise(
3271
+ ::NoResponse::Models::Errors::APIStatusError.new(
3272
+ status_code: http_response.status,
3273
+ body: http_response.env.response_body,
3274
+ raw_response: http_response
3275
+ ),
3276
+ "Unknown content type received"
3277
+ )
3278
+ end
3279
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
3280
+ raise(
3281
+ ::NoResponse::Models::Errors::APIStatusError.new(
3282
+ status_code: http_response.status,
3283
+ body: http_response.env.response_body,
3284
+ raw_response: http_response
3285
+ ),
3286
+ "API error occurred"
3287
+ )
3288
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
3289
+ raise(
3290
+ ::NoResponse::Models::Errors::APIStatusError.new(
3291
+ status_code: http_response.status,
3292
+ body: http_response.env.response_body,
3293
+ raw_response: http_response
3294
+ ),
3295
+ "API error occurred"
3296
+ )
3297
+ else
3298
+ raise(
3299
+ ::NoResponse::Models::Errors::APIStatusError.new(
3300
+ status_code: http_response.status,
3301
+ body: http_response.env.response_body,
3302
+ raw_response: http_response
3303
+ ),
3304
+ "Unknown status code received"
3305
+ )
3306
+
3307
+ end
3308
+ end
3309
+
3310
+ sig {
3311
+ params(
3312
+ account_id: ::String,
3313
+ response_mode: T.nilable(Models::Shared::ResponseMode),
3314
+ retries: T.nilable(Utils::RetryConfig),
3315
+ timeout_ms: T.nilable(Integer),
3316
+ http_headers: T.nilable(T::Hash[T.any(String, Symbol), String])
3317
+ )
3318
+ .returns(Models::Operations::ExportAccountResponse)
3319
+ }
3320
+ def export(account_id:, response_mode: nil, retries: nil, timeout_ms: nil, http_headers: nil)
3321
+ # export - Export an account
3322
+ # Retrieve one consistent snapshot of retained customer-accessible records, including assessment revisions, account decisions, feedback, key associations, enforcements and request diagnostics. Secrets, restricted source information, other customers' data and legacy free-text notes are excluded. The same standard/detailed permissions apply. An export exceeding 10000 records or 8 MiB returns export_too_large without a partial result. Historical decisions that were not captured are identified as an exclusion.
3323
+ request = Models::Operations::ExportAccountRequest.new(
3324
+ account_id: account_id,
3325
+ response_mode: response_mode
3326
+ )
3327
+ url, params = @sdk_configuration.get_server_details
3328
+ base_url = Utils.template_url(url, params)
3329
+ url = Utils.generate_url(
3330
+ Models::Operations::ExportAccountRequest,
3331
+ base_url,
3332
+ "/v1/accounts/{account_id}/export",
3333
+ request
3334
+ )
3335
+ headers = {}
3336
+ headers = T.cast(headers, T::Hash[String, String])
3337
+ query_params = Utils.get_query_params(Models::Operations::ExportAccountRequest, request, nil)
3338
+ headers["Accept"] = "application/json"
3339
+ headers["user-agent"] = @sdk_configuration.user_agent
3340
+ retries ||= @sdk_configuration.retry_config
3341
+ retries ||= Utils::RetryConfig.new(
3342
+ backoff: Utils::BackoffStrategy.new(
3343
+ exponent: 2.0,
3344
+ initial_interval: 500,
3345
+ max_elapsed_time: 30_000,
3346
+ max_interval: 8000
3347
+ ),
3348
+ retry_connection_errors: true,
3349
+ strategy: "backoff"
3350
+ )
3351
+ retry_options = retries.to_faraday_retry_options(initial_time: Time.now)
3352
+ retry_options[:retry_statuses] = [408, 429, 500, 501, 502, 503, 504, 505]
3353
+
3354
+ security = @sdk_configuration.security_source&.call
3355
+
3356
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
3357
+ timeout ||= @sdk_configuration.timeout
3358
+
3359
+ connection = @sdk_configuration.client.dup
3360
+ connection.use(Utils::RetryMiddleware, retry_options)
3361
+
3362
+ hook_ctx = SDKHooks::HookContext.new(
3363
+ config: @sdk_configuration,
3364
+ base_url: base_url,
3365
+ oauth2_scopes: nil,
3366
+ operation_id: "exportAccount",
3367
+ security_source: @sdk_configuration.security_source
3368
+ )
3369
+
3370
+ error = T.let(nil, T.nilable(StandardError))
3371
+ http_response = T.let(nil, T.nilable(Faraday::Response))
3372
+
3373
+ begin
3374
+ http_response = T.must(connection).get(url) do |req|
3375
+ req.headers.merge!(headers)
3376
+ req.options.timeout = timeout unless timeout.nil?
3377
+ req.params = query_params
3378
+ Utils.configure_request_security(req, security)
3379
+ http_headers&.each do |key, value|
3380
+ req.headers[key.to_s] = value
3381
+ end
3382
+
3383
+ @sdk_configuration.hooks.before_request(
3384
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
3385
+ hook_ctx: hook_ctx
3386
+ ),
3387
+ request: req
3388
+ )
3389
+ end
3390
+
3391
+ rescue StandardError => e
3392
+ error = e
3393
+ ensure
3394
+ if http_response.nil? || Utils.error_status?(http_response.status)
3395
+ http_response = @sdk_configuration.hooks.after_error(
3396
+ error: error,
3397
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
3398
+ hook_ctx: hook_ctx
3399
+ ),
3400
+ response: http_response
3401
+ )
3402
+ else
3403
+ http_response = @sdk_configuration.hooks.after_success(
3404
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3405
+ hook_ctx: hook_ctx
3406
+ ),
3407
+ response: http_response
3408
+ )
3409
+ end
3410
+
3411
+ if http_response.nil?
3412
+ raise error if !error.nil?
3413
+ raise "no response"
3414
+ end
3415
+ end
3416
+
3417
+ content_type = http_response.headers.fetch("Content-Type", "application/octet-stream")
3418
+ if Utils.match_status_code(http_response.status, ["200"])
3419
+ if Utils.match_content_type(content_type, "application/json")
3420
+ @sdk_configuration.hooks.after_success(
3421
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3422
+ hook_ctx: hook_ctx
3423
+ ),
3424
+ response: http_response
3425
+ )
3426
+ response_data = http_response.env.response_body
3427
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Shared::AccountExport)
3428
+ result = obj
3429
+ response = Models::Operations::ExportAccountResponse.new(
3430
+ result: result,
3431
+ headers: http_response.headers
3432
+ )
3433
+
3434
+ return response
3435
+ else
3436
+ raise(
3437
+ ::NoResponse::Models::Errors::APIStatusError.new(
3438
+ status_code: http_response.status,
3439
+ body: http_response.env.response_body,
3440
+ raw_response: http_response
3441
+ ),
3442
+ "Unknown content type received"
3443
+ )
3444
+ end
3445
+ elsif Utils.match_status_code(http_response.status, ["400"])
3446
+ if Utils.match_content_type(content_type, "application/problem+json")
3447
+ @sdk_configuration.hooks.after_success(
3448
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3449
+ hook_ctx: hook_ctx
3450
+ ),
3451
+ response: http_response
3452
+ )
3453
+ response_data = http_response.env.response_body
3454
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::BadRequestError)
3455
+ raise obj
3456
+ else
3457
+ raise(
3458
+ ::NoResponse::Models::Errors::APIStatusError.new(
3459
+ status_code: http_response.status,
3460
+ body: http_response.env.response_body,
3461
+ raw_response: http_response
3462
+ ),
3463
+ "Unknown content type received"
3464
+ )
3465
+ end
3466
+ elsif Utils.match_status_code(http_response.status, ["401"])
3467
+ if Utils.match_content_type(content_type, "application/problem+json")
3468
+ @sdk_configuration.hooks.after_success(
3469
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3470
+ hook_ctx: hook_ctx
3471
+ ),
3472
+ response: http_response
3473
+ )
3474
+ response_data = http_response.env.response_body
3475
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::AuthenticationError)
3476
+ raise obj
3477
+ else
3478
+ raise(
3479
+ ::NoResponse::Models::Errors::APIStatusError.new(
3480
+ status_code: http_response.status,
3481
+ body: http_response.env.response_body,
3482
+ raw_response: http_response
3483
+ ),
3484
+ "Unknown content type received"
3485
+ )
3486
+ end
3487
+ elsif Utils.match_status_code(http_response.status, ["403"])
3488
+ if Utils.match_content_type(content_type, "application/problem+json")
3489
+ @sdk_configuration.hooks.after_success(
3490
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3491
+ hook_ctx: hook_ctx
3492
+ ),
3493
+ response: http_response
3494
+ )
3495
+ response_data = http_response.env.response_body
3496
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::PermissionDeniedError)
3497
+ raise obj
3498
+ else
3499
+ raise(
3500
+ ::NoResponse::Models::Errors::APIStatusError.new(
3501
+ status_code: http_response.status,
3502
+ body: http_response.env.response_body,
3503
+ raw_response: http_response
3504
+ ),
3505
+ "Unknown content type received"
3506
+ )
3507
+ end
3508
+ elsif Utils.match_status_code(http_response.status, ["404"])
3509
+ if Utils.match_content_type(content_type, "application/problem+json")
3510
+ @sdk_configuration.hooks.after_success(
3511
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3512
+ hook_ctx: hook_ctx
3513
+ ),
3514
+ response: http_response
3515
+ )
3516
+ response_data = http_response.env.response_body
3517
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::NotFoundError)
3518
+ raise obj
3519
+ else
3520
+ raise(
3521
+ ::NoResponse::Models::Errors::APIStatusError.new(
3522
+ status_code: http_response.status,
3523
+ body: http_response.env.response_body,
3524
+ raw_response: http_response
3525
+ ),
3526
+ "Unknown content type received"
3527
+ )
3528
+ end
3529
+ elsif Utils.match_status_code(http_response.status, ["409"])
3530
+ if Utils.match_content_type(content_type, "application/problem+json")
3531
+ @sdk_configuration.hooks.after_success(
3532
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3533
+ hook_ctx: hook_ctx
3534
+ ),
3535
+ response: http_response
3536
+ )
3537
+ response_data = http_response.env.response_body
3538
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::ConflictError)
3539
+ raise obj
3540
+ else
3541
+ raise(
3542
+ ::NoResponse::Models::Errors::APIStatusError.new(
3543
+ status_code: http_response.status,
3544
+ body: http_response.env.response_body,
3545
+ raw_response: http_response
3546
+ ),
3547
+ "Unknown content type received"
3548
+ )
3549
+ end
3550
+ elsif Utils.match_status_code(http_response.status, ["429"])
3551
+ if Utils.match_content_type(content_type, "application/problem+json")
3552
+ @sdk_configuration.hooks.after_success(
3553
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
3554
+ hook_ctx: hook_ctx
3555
+ ),
3556
+ response: http_response
3557
+ )
3558
+ response_data = http_response.env.response_body
3559
+ obj = Crystalline.unmarshal_json(JSON.parse(response_data), Models::Errors::RateLimitError)
3560
+ raise obj
3561
+ else
3562
+ raise(
3563
+ ::NoResponse::Models::Errors::APIStatusError.new(
3564
+ status_code: http_response.status,
3565
+ body: http_response.env.response_body,
3566
+ raw_response: http_response
3567
+ ),
3568
+ "Unknown content type received"
3569
+ )
3570
+ end
3571
+ elsif Utils.match_status_code(http_response.status, ["4XX"])
3572
+ raise(
3573
+ ::NoResponse::Models::Errors::APIStatusError.new(
3574
+ status_code: http_response.status,
3575
+ body: http_response.env.response_body,
3576
+ raw_response: http_response
3577
+ ),
3578
+ "API error occurred"
3579
+ )
3580
+ elsif Utils.match_status_code(http_response.status, ["5XX"])
3581
+ raise(
3582
+ ::NoResponse::Models::Errors::APIStatusError.new(
3583
+ status_code: http_response.status,
3584
+ body: http_response.env.response_body,
3585
+ raw_response: http_response
3586
+ ),
3587
+ "API error occurred"
3588
+ )
3589
+ else
3590
+ raise(
3591
+ ::NoResponse::Models::Errors::APIStatusError.new(
3592
+ status_code: http_response.status,
3593
+ body: http_response.env.response_body,
3594
+ raw_response: http_response
3595
+ ),
3596
+ "Unknown status code received"
3597
+ )
3598
+
3599
+ end
3600
+ end
1533
3601
  end
1534
3602
  end