astrada 2.0.0__tar.gz

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 (306) hide show
  1. astrada-2.0.0/LICENSE +21 -0
  2. astrada-2.0.0/PKG-INFO +607 -0
  3. astrada-2.0.0/README.md +582 -0
  4. astrada-2.0.0/astrada/__init__.py +421 -0
  5. astrada-2.0.0/astrada/_lenient.py +28 -0
  6. astrada-2.0.0/astrada/_retry.py +102 -0
  7. astrada-2.0.0/astrada/_sandbox_guard.py +47 -0
  8. astrada-2.0.0/astrada/_sandbox_routes.py +19 -0
  9. astrada-2.0.0/astrada/_services.py +49 -0
  10. astrada-2.0.0/astrada/api/__init__.py +16 -0
  11. astrada-2.0.0/astrada/api/bin_lookup_api.py +318 -0
  12. astrada-2.0.0/astrada/api/card_api.py +1317 -0
  13. astrada-2.0.0/astrada/api/card_subscription_api.py +1096 -0
  14. astrada-2.0.0/astrada/api/card_verification_api.py +898 -0
  15. astrada-2.0.0/astrada/api/enrollment_links_api.py +1506 -0
  16. astrada-2.0.0/astrada/api/enrollment_methods_api.py +330 -0
  17. astrada-2.0.0/astrada/api/network_bulk_enrollments_api.py +1212 -0
  18. astrada-2.0.0/astrada/api/network_bulk_feeds_api.py +1246 -0
  19. astrada-2.0.0/astrada/api/subaccounts_api.py +1210 -0
  20. astrada-2.0.0/astrada/api/transaction_messages_api.py +596 -0
  21. astrada-2.0.0/astrada/api/transactions_api.py +787 -0
  22. astrada-2.0.0/astrada/api/webhooks_api.py +1503 -0
  23. astrada-2.0.0/astrada/api_client.py +812 -0
  24. astrada-2.0.0/astrada/api_response.py +21 -0
  25. astrada-2.0.0/astrada/auth_client.py +241 -0
  26. astrada-2.0.0/astrada/banking/__init__.py +198 -0
  27. astrada-2.0.0/astrada/banking/_services.py +28 -0
  28. astrada-2.0.0/astrada/banking/_staff_only.py +103 -0
  29. astrada-2.0.0/astrada/banking/api/__init__.py +9 -0
  30. astrada-2.0.0/astrada/banking/api/bank_accounts_api.py +2718 -0
  31. astrada-2.0.0/astrada/banking/api/bank_links_api.py +1857 -0
  32. astrada-2.0.0/astrada/banking/api/bank_subscriptions_api.py +958 -0
  33. astrada-2.0.0/astrada/banking/api/bank_transactions_api.py +1121 -0
  34. astrada-2.0.0/astrada/banking/api/transaction_matches_api.py +774 -0
  35. astrada-2.0.0/astrada/banking/api_client.py +815 -0
  36. astrada-2.0.0/astrada/banking/api_response.py +21 -0
  37. astrada-2.0.0/astrada/banking/configuration.py +674 -0
  38. astrada-2.0.0/astrada/banking/exceptions.py +36 -0
  39. astrada-2.0.0/astrada/banking/models/__init__.py +73 -0
  40. astrada-2.0.0/astrada/banking/models/bank_account.py +232 -0
  41. astrada-2.0.0/astrada/banking/models/bank_account_backfill_params.py +109 -0
  42. astrada-2.0.0/astrada/banking/models/bank_account_backfill_result.py +109 -0
  43. astrada-2.0.0/astrada/banking/models/bank_account_cards_update.py +111 -0
  44. astrada-2.0.0/astrada/banking/models/bank_account_cards_update_backfill.py +107 -0
  45. astrada-2.0.0/astrada/banking/models/bank_account_disconnect.py +118 -0
  46. astrada-2.0.0/astrada/banking/models/bank_account_link_cards_params.py +92 -0
  47. astrada-2.0.0/astrada/banking/models/bank_account_link_cards_result.py +105 -0
  48. astrada-2.0.0/astrada/banking/models/bank_account_links.py +118 -0
  49. astrada-2.0.0/astrada/banking/models/bank_account_list.py +118 -0
  50. astrada-2.0.0/astrada/banking/models/bank_account_maintenance_params.py +98 -0
  51. astrada-2.0.0/astrada/banking/models/bank_account_maintenance_result.py +136 -0
  52. astrada-2.0.0/astrada/banking/models/bank_account_maintenance_result_cardholder_cards.py +124 -0
  53. astrada-2.0.0/astrada/banking/models/bank_account_maintenance_result_junction_last4.py +108 -0
  54. astrada-2.0.0/astrada/banking/models/bank_account_maintenance_result_minted_value.py +109 -0
  55. astrada-2.0.0/astrada/banking/models/bank_account_refresh_result.py +110 -0
  56. astrada-2.0.0/astrada/banking/models/bank_account_transactions_refresh_result.py +110 -0
  57. astrada-2.0.0/astrada/banking/models/bank_account_update_params.py +173 -0
  58. astrada-2.0.0/astrada/banking/models/bank_account_update_result.py +118 -0
  59. astrada-2.0.0/astrada/banking/models/bank_account_update_result_backfill.py +106 -0
  60. astrada-2.0.0/astrada/banking/models/bank_feed_card.py +135 -0
  61. astrada-2.0.0/astrada/banking/models/bank_institution_incident.py +127 -0
  62. astrada-2.0.0/astrada/banking/models/bank_link.py +204 -0
  63. astrada-2.0.0/astrada/banking/models/bank_link_bank_account.py +158 -0
  64. astrada-2.0.0/astrada/banking/models/bank_link_consent.py +154 -0
  65. astrada-2.0.0/astrada/banking/models/bank_link_create_params.py +195 -0
  66. astrada-2.0.0/astrada/banking/models/bank_link_create_params_filters.py +118 -0
  67. astrada-2.0.0/astrada/banking/models/bank_link_filters.py +117 -0
  68. astrada-2.0.0/astrada/banking/models/bank_link_last_mint_failure.py +120 -0
  69. astrada-2.0.0/astrada/banking/models/bank_link_last_rejection.py +112 -0
  70. astrada-2.0.0/astrada/banking/models/bank_link_links.py +117 -0
  71. astrada-2.0.0/astrada/banking/models/bank_link_list.py +118 -0
  72. astrada-2.0.0/astrada/banking/models/bank_link_sync_params.py +117 -0
  73. astrada-2.0.0/astrada/banking/models/bank_link_sync_result.py +104 -0
  74. astrada-2.0.0/astrada/banking/models/bank_link_update_params.py +118 -0
  75. astrada-2.0.0/astrada/banking/models/bank_subscription.py +190 -0
  76. astrada-2.0.0/astrada/banking/models/bank_subscription_institution_health.py +139 -0
  77. astrada-2.0.0/astrada/banking/models/bank_subscription_list.py +118 -0
  78. astrada-2.0.0/astrada/banking/models/bank_subscription_webhook.py +119 -0
  79. astrada-2.0.0/astrada/banking/models/bank_transaction.py +203 -0
  80. astrada-2.0.0/astrada/banking/models/bank_transaction_links.py +123 -0
  81. astrada-2.0.0/astrada/banking/models/bank_transaction_list.py +118 -0
  82. astrada-2.0.0/astrada/banking/models/bank_transaction_settlement.py +137 -0
  83. astrada-2.0.0/astrada/banking/models/bank_transaction_webhook_failure.py +106 -0
  84. astrada-2.0.0/astrada/banking/models/bank_transaction_webhooks_params.py +123 -0
  85. astrada-2.0.0/astrada/banking/models/bank_transaction_webhooks_result.py +126 -0
  86. astrada-2.0.0/astrada/banking/models/banking_error.py +114 -0
  87. astrada-2.0.0/astrada/banking/models/cursor_pagination.py +106 -0
  88. astrada-2.0.0/astrada/banking/models/link.py +118 -0
  89. astrada-2.0.0/astrada/banking/models/problem.py +110 -0
  90. astrada-2.0.0/astrada/banking/models/transaction_match.py +157 -0
  91. astrada-2.0.0/astrada/banking/models/transaction_match_bank_transaction.py +117 -0
  92. astrada-2.0.0/astrada/banking/models/transaction_match_card_transaction.py +118 -0
  93. astrada-2.0.0/astrada/banking/models/transaction_match_links.py +123 -0
  94. astrada-2.0.0/astrada/banking/models/transaction_match_list.py +118 -0
  95. astrada-2.0.0/astrada/banking/models/transaction_match_reason.py +135 -0
  96. astrada-2.0.0/astrada/banking/py.typed +0 -0
  97. astrada-2.0.0/astrada/banking/rest.py +289 -0
  98. astrada-2.0.0/astrada/client.py +398 -0
  99. astrada-2.0.0/astrada/configuration.py +674 -0
  100. astrada-2.0.0/astrada/environments.py +47 -0
  101. astrada-2.0.0/astrada/exceptions.py +381 -0
  102. astrada-2.0.0/astrada/models/__init__.py +173 -0
  103. astrada-2.0.0/astrada/models/amex_countries_or_wildcard.py +194 -0
  104. astrada-2.0.0/astrada/models/bank_linking_policy.py +200 -0
  105. astrada-2.0.0/astrada/models/bin_lookup.py +212 -0
  106. astrada-2.0.0/astrada/models/bin_lookup_validation_problem.py +116 -0
  107. astrada-2.0.0/astrada/models/bin_lookup_validation_problem_item.py +108 -0
  108. astrada-2.0.0/astrada/models/bin_lookup_warning.py +114 -0
  109. astrada-2.0.0/astrada/models/card.py +166 -0
  110. astrada-2.0.0/astrada/models/card_embedded.py +108 -0
  111. astrada-2.0.0/astrada/models/card_links.py +113 -0
  112. astrada-2.0.0/astrada/models/card_list.py +116 -0
  113. astrada-2.0.0/astrada/models/card_list_embedded.py +112 -0
  114. astrada-2.0.0/astrada/models/card_subscription.py +176 -0
  115. astrada-2.0.0/astrada/models/card_subscription_deactivation_reason.py +57 -0
  116. astrada-2.0.0/astrada/models/card_subscription_embedded.py +114 -0
  117. astrada-2.0.0/astrada/models/card_subscription_links.py +128 -0
  118. astrada-2.0.0/astrada/models/card_subscription_list.py +116 -0
  119. astrada-2.0.0/astrada/models/card_subscription_list_embedded.py +112 -0
  120. astrada-2.0.0/astrada/models/card_subscription_update_params.py +105 -0
  121. astrada-2.0.0/astrada/models/card_verification.py +186 -0
  122. astrada-2.0.0/astrada/models/card_verification_links.py +118 -0
  123. astrada-2.0.0/astrada/models/card_verification_list.py +116 -0
  124. astrada-2.0.0/astrada/models/card_verification_list_embedded.py +112 -0
  125. astrada-2.0.0/astrada/models/card_verification_unlock_params.py +105 -0
  126. astrada-2.0.0/astrada/models/card_verification_unlock_result.py +106 -0
  127. astrada-2.0.0/astrada/models/cardholder.py +147 -0
  128. astrada-2.0.0/astrada/models/cardholder_corporate.py +134 -0
  129. astrada-2.0.0/astrada/models/cardholder_corporate_legal_entity.py +107 -0
  130. astrada-2.0.0/astrada/models/cardholder_update_params.py +106 -0
  131. astrada-2.0.0/astrada/models/cardholder_update_params_corporate.py +108 -0
  132. astrada-2.0.0/astrada/models/conflict.py +121 -0
  133. astrada-2.0.0/astrada/models/consent_policy.py +129 -0
  134. astrada-2.0.0/astrada/models/create_subaccount_configurations.py +120 -0
  135. astrada-2.0.0/astrada/models/create_subaccount_configurations_amex.py +120 -0
  136. astrada-2.0.0/astrada/models/create_subaccount_configurations_amex_bulk_enrollment.py +128 -0
  137. astrada-2.0.0/astrada/models/create_subaccount_configurations_amex_single_enrollment.py +128 -0
  138. astrada-2.0.0/astrada/models/create_subaccount_configurations_mastercard.py +120 -0
  139. astrada-2.0.0/astrada/models/create_subaccount_configurations_mastercard_bulk_enrollment.py +128 -0
  140. astrada-2.0.0/astrada/models/create_subaccount_configurations_mastercard_single_enrollment.py +128 -0
  141. astrada-2.0.0/astrada/models/create_subaccount_configurations_visa.py +120 -0
  142. astrada-2.0.0/astrada/models/create_subaccount_configurations_visa_bulk_enrollment.py +128 -0
  143. astrada-2.0.0/astrada/models/create_subaccount_configurations_visa_single_enrollment.py +128 -0
  144. astrada-2.0.0/astrada/models/customer_enrollment_policy.py +145 -0
  145. astrada-2.0.0/astrada/models/enrollment_link.py +172 -0
  146. astrada-2.0.0/astrada/models/enrollment_link_conflict_problem.py +124 -0
  147. astrada-2.0.0/astrada/models/enrollment_link_create_params.py +139 -0
  148. astrada-2.0.0/astrada/models/enrollment_link_create_result.py +174 -0
  149. astrada-2.0.0/astrada/models/enrollment_link_create_validation_problem.py +137 -0
  150. astrada-2.0.0/astrada/models/enrollment_link_created_by.py +114 -0
  151. astrada-2.0.0/astrada/models/enrollment_link_detail.py +182 -0
  152. astrada-2.0.0/astrada/models/enrollment_link_forbidden_problem.py +127 -0
  153. astrada-2.0.0/astrada/models/enrollment_link_list.py +114 -0
  154. astrada-2.0.0/astrada/models/enrollment_link_list_embedded.py +112 -0
  155. astrada-2.0.0/astrada/models/enrollment_link_list_validation_problem.py +137 -0
  156. astrada-2.0.0/astrada/models/enrollment_link_not_found_problem.py +124 -0
  157. astrada-2.0.0/astrada/models/enrollment_link_rate_limited_problem.py +124 -0
  158. astrada-2.0.0/astrada/models/enrollment_link_session.py +128 -0
  159. astrada-2.0.0/astrada/models/enrollment_link_session_outcome.py +112 -0
  160. astrada-2.0.0/astrada/models/enrollment_link_subaccount_not_found_problem.py +124 -0
  161. astrada-2.0.0/astrada/models/enrollment_methods_params.py +116 -0
  162. astrada-2.0.0/astrada/models/enrollment_methods_result.py +152 -0
  163. astrada-2.0.0/astrada/models/enrollment_methods_result_bin_info.py +145 -0
  164. astrada-2.0.0/astrada/models/enrollment_methods_result_single_decision.py +117 -0
  165. astrada-2.0.0/astrada/models/enrollment_policy.py +166 -0
  166. astrada-2.0.0/astrada/models/failure_reason.py +130 -0
  167. astrada-2.0.0/astrada/models/failure_reason_acs_references.py +108 -0
  168. astrada-2.0.0/astrada/models/link.py +118 -0
  169. astrada-2.0.0/astrada/models/mastercard_countries_or_wildcard.py +194 -0
  170. astrada-2.0.0/astrada/models/network_blocked_card_rule.py +125 -0
  171. astrada-2.0.0/astrada/models/network_bulk_bank_contact.py +106 -0
  172. astrada-2.0.0/astrada/models/network_bulk_bank_contact_params.py +107 -0
  173. astrada-2.0.0/astrada/models/network_bulk_company_params.py +105 -0
  174. astrada-2.0.0/astrada/models/network_bulk_confirmation.py +194 -0
  175. astrada-2.0.0/astrada/models/network_bulk_confirmation_bin_info.py +130 -0
  176. astrada-2.0.0/astrada/models/network_bulk_confirmation_card_admin.py +106 -0
  177. astrada-2.0.0/astrada/models/network_bulk_confirmation_company.py +104 -0
  178. astrada-2.0.0/astrada/models/network_bulk_confirmation_create_params.py +167 -0
  179. astrada-2.0.0/astrada/models/network_bulk_confirmation_create_params_bin_info.py +111 -0
  180. astrada-2.0.0/astrada/models/network_bulk_confirmation_create_params_card_admin.py +107 -0
  181. astrada-2.0.0/astrada/models/network_bulk_confirmation_create_result.py +173 -0
  182. astrada-2.0.0/astrada/models/network_bulk_confirmation_summary.py +134 -0
  183. astrada-2.0.0/astrada/models/network_bulk_enrollment.py +231 -0
  184. astrada-2.0.0/astrada/models/network_bulk_enrollment_bin_info.py +130 -0
  185. astrada-2.0.0/astrada/models/network_bulk_enrollment_card_admin.py +106 -0
  186. astrada-2.0.0/astrada/models/network_bulk_enrollment_company.py +104 -0
  187. astrada-2.0.0/astrada/models/network_bulk_enrollment_consent.py +107 -0
  188. astrada-2.0.0/astrada/models/network_bulk_enrollment_create_params.py +185 -0
  189. astrada-2.0.0/astrada/models/network_bulk_enrollment_create_params_bin_info.py +111 -0
  190. astrada-2.0.0/astrada/models/network_bulk_enrollment_create_params_card_admin.py +107 -0
  191. astrada-2.0.0/astrada/models/network_bulk_enrollment_create_params_consent.py +107 -0
  192. astrada-2.0.0/astrada/models/network_bulk_enrollment_create_result.py +173 -0
  193. astrada-2.0.0/astrada/models/network_bulk_enrollment_links.py +113 -0
  194. astrada-2.0.0/astrada/models/network_bulk_enrollment_open.py +123 -0
  195. astrada-2.0.0/astrada/models/network_bulk_enrollment_summary.py +152 -0
  196. astrada-2.0.0/astrada/models/network_bulk_enrollment_summary_links.py +108 -0
  197. astrada-2.0.0/astrada/models/network_bulk_feed_create_amex.py +155 -0
  198. astrada-2.0.0/astrada/models/network_bulk_feed_create_common.py +132 -0
  199. astrada-2.0.0/astrada/models/network_bulk_feed_create_mastercard.py +155 -0
  200. astrada-2.0.0/astrada/models/network_bulk_feed_create_params.py +190 -0
  201. astrada-2.0.0/astrada/models/network_bulk_feed_create_visa.py +155 -0
  202. astrada-2.0.0/astrada/models/network_bulk_feed_list.py +116 -0
  203. astrada-2.0.0/astrada/models/network_bulk_feed_list_embedded.py +112 -0
  204. astrada-2.0.0/astrada/models/network_bulk_feed_update_params.py +108 -0
  205. astrada-2.0.0/astrada/models/network_bulk_feeds.py +180 -0
  206. astrada-2.0.0/astrada/models/offset_page_links.py +128 -0
  207. astrada-2.0.0/astrada/models/page_links.py +113 -0
  208. astrada-2.0.0/astrada/models/plaid_end_customer.py +109 -0
  209. astrada-2.0.0/astrada/models/problem.py +110 -0
  210. astrada-2.0.0/astrada/models/raw_transaction_message.py +110 -0
  211. astrada-2.0.0/astrada/models/raw_transaction_message_links.py +113 -0
  212. astrada-2.0.0/astrada/models/self_links.py +108 -0
  213. astrada-2.0.0/astrada/models/subaccount.py +206 -0
  214. astrada-2.0.0/astrada/models/subaccount_amex_product.py +124 -0
  215. astrada-2.0.0/astrada/models/subaccount_amex_product_clearing.py +104 -0
  216. astrada-2.0.0/astrada/models/subaccount_amex_product_real_time_auth.py +104 -0
  217. astrada-2.0.0/astrada/models/subaccount_configuration.py +107 -0
  218. astrada-2.0.0/astrada/models/subaccount_configuration_amex.py +111 -0
  219. astrada-2.0.0/astrada/models/subaccount_configuration_amex_bulk_enrollment.py +119 -0
  220. astrada-2.0.0/astrada/models/subaccount_configuration_amex_single_enrollment.py +119 -0
  221. astrada-2.0.0/astrada/models/subaccount_configuration_mastercard.py +111 -0
  222. astrada-2.0.0/astrada/models/subaccount_configuration_mastercard_bulk_enrollment.py +119 -0
  223. astrada-2.0.0/astrada/models/subaccount_configuration_mastercard_single_enrollment.py +119 -0
  224. astrada-2.0.0/astrada/models/subaccount_configuration_visa.py +111 -0
  225. astrada-2.0.0/astrada/models/subaccount_configuration_visa_bulk_enrollment.py +119 -0
  226. astrada-2.0.0/astrada/models/subaccount_configuration_visa_single_enrollment.py +119 -0
  227. astrada-2.0.0/astrada/models/subaccount_create_params.py +110 -0
  228. astrada-2.0.0/astrada/models/subaccount_enrollment_policy.py +168 -0
  229. astrada-2.0.0/astrada/models/subaccount_links.py +113 -0
  230. astrada-2.0.0/astrada/models/subaccount_list.py +114 -0
  231. astrada-2.0.0/astrada/models/subaccount_list_embedded.py +112 -0
  232. astrada-2.0.0/astrada/models/subaccount_network_blocked_cards_value.py +121 -0
  233. astrada-2.0.0/astrada/models/subaccount_update_params.py +122 -0
  234. astrada-2.0.0/astrada/models/subaccount_update_result.py +208 -0
  235. astrada-2.0.0/astrada/models/team_link.py +112 -0
  236. astrada-2.0.0/astrada/models/transaction.py +181 -0
  237. astrada-2.0.0/astrada/models/transaction_acceptor.py +130 -0
  238. astrada-2.0.0/astrada/models/transaction_embedded.py +120 -0
  239. astrada-2.0.0/astrada/models/transaction_links.py +127 -0
  240. astrada-2.0.0/astrada/models/transaction_list.py +114 -0
  241. astrada-2.0.0/astrada/models/transaction_list_embedded.py +112 -0
  242. astrada-2.0.0/astrada/models/transaction_message.py +230 -0
  243. astrada-2.0.0/astrada/models/transaction_message_acceptor.py +151 -0
  244. astrada-2.0.0/astrada/models/transaction_message_bank_data.py +126 -0
  245. astrada-2.0.0/astrada/models/transaction_message_bank_data_personal_finance_category.py +111 -0
  246. astrada-2.0.0/astrada/models/transaction_message_links.py +113 -0
  247. astrada-2.0.0/astrada/models/unprocessable_entity.py +114 -0
  248. astrada-2.0.0/astrada/models/validation_problem.py +116 -0
  249. astrada-2.0.0/astrada/models/validation_problem_item.py +106 -0
  250. astrada-2.0.0/astrada/models/verification_policy.py +134 -0
  251. astrada-2.0.0/astrada/models/visa_countries_or_wildcard.py +194 -0
  252. astrada-2.0.0/astrada/models/webhook.py +140 -0
  253. astrada-2.0.0/astrada/models/webhook_create_params.py +122 -0
  254. astrada-2.0.0/astrada/models/webhook_create_result.py +142 -0
  255. astrada-2.0.0/astrada/models/webhook_list.py +101 -0
  256. astrada-2.0.0/astrada/models/webhook_list_embedded.py +112 -0
  257. astrada-2.0.0/astrada/models/webhook_list_links.py +113 -0
  258. astrada-2.0.0/astrada/models/webhook_update_params.py +109 -0
  259. astrada-2.0.0/astrada/pagination.py +76 -0
  260. astrada-2.0.0/astrada/py.typed +0 -0
  261. astrada-2.0.0/astrada/rest.py +289 -0
  262. astrada-2.0.0/astrada/sandbox/__init__.py +114 -0
  263. astrada-2.0.0/astrada/sandbox/_services.py +24 -0
  264. astrada-2.0.0/astrada/sandbox/api/__init__.py +8 -0
  265. astrada-2.0.0/astrada/sandbox/api/card_subscription_api.py +316 -0
  266. astrada-2.0.0/astrada/sandbox/api/network_bulk_feeds_api.py +316 -0
  267. astrada-2.0.0/astrada/sandbox/api/sandbox_simulation_api.py +2093 -0
  268. astrada-2.0.0/astrada/sandbox/api/subaccounts_api.py +316 -0
  269. astrada-2.0.0/astrada/sandbox/api_client.py +826 -0
  270. astrada-2.0.0/astrada/sandbox/api_response.py +21 -0
  271. astrada-2.0.0/astrada/sandbox/configuration.py +674 -0
  272. astrada-2.0.0/astrada/sandbox/exceptions.py +36 -0
  273. astrada-2.0.0/astrada/sandbox/models/__init__.py +32 -0
  274. astrada-2.0.0/astrada/sandbox/models/conflict.py +121 -0
  275. astrada-2.0.0/astrada/sandbox/models/problem.py +110 -0
  276. astrada-2.0.0/astrada/sandbox/models/simulate_bulk_feed_file_gl_request.py +119 -0
  277. astrada-2.0.0/astrada/sandbox/models/simulate_bulk_feed_file_smartdata_request.py +119 -0
  278. astrada-2.0.0/astrada/sandbox/models/simulate_bulk_feed_file_vbds_request.py +119 -0
  279. astrada-2.0.0/astrada/sandbox/models/simulate_bulk_feed_file_vcf_request.py +119 -0
  280. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_accepted.py +105 -0
  281. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_message_request.py +118 -0
  282. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_request.py +142 -0
  283. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_request_merchant.py +130 -0
  284. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_scenario_accepted.py +113 -0
  285. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_scenario_request.py +148 -0
  286. astrada-2.0.0/astrada/sandbox/models/simulate_transaction_scenario_transaction.py +106 -0
  287. astrada-2.0.0/astrada/sandbox/models/validation_problem.py +116 -0
  288. astrada-2.0.0/astrada/sandbox/models/validation_problem_item.py +106 -0
  289. astrada-2.0.0/astrada/sandbox/py.typed +0 -0
  290. astrada-2.0.0/astrada/sandbox/rest.py +289 -0
  291. astrada-2.0.0/astrada/testing/__init__.py +197 -0
  292. astrada-2.0.0/astrada/testing/responses.json +2429 -0
  293. astrada-2.0.0/astrada/webhooks.py +309 -0
  294. astrada-2.0.0/astrada.egg-info/PKG-INFO +607 -0
  295. astrada-2.0.0/astrada.egg-info/SOURCES.txt +304 -0
  296. astrada-2.0.0/astrada.egg-info/dependency_links.txt +1 -0
  297. astrada-2.0.0/astrada.egg-info/requires.txt +4 -0
  298. astrada-2.0.0/astrada.egg-info/top_level.txt +1 -0
  299. astrada-2.0.0/pyproject.toml +117 -0
  300. astrada-2.0.0/setup.cfg +4 -0
  301. astrada-2.0.0/test/test_auth_client.py +238 -0
  302. astrada-2.0.0/test/test_banking.py +57 -0
  303. astrada-2.0.0/test/test_banking_default_host.py +20 -0
  304. astrada-2.0.0/test/test_client.py +1018 -0
  305. astrada-2.0.0/test/test_doc_examples.py +144 -0
  306. astrada-2.0.0/test/test_webhooks.py +232 -0
astrada-2.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Fidel Limited DBA Astrada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
astrada-2.0.0/PKG-INFO ADDED
@@ -0,0 +1,607 @@
1
+ Metadata-Version: 2.4
2
+ Name: astrada
3
+ Version: 2.0.0
4
+ Summary: The Astrada API client for Python
5
+ Author-email: Peter Swanson <email@peterswanson.tech>, Astrada <developer@astrada.co>
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/FidelLimited/astrada-python
8
+ Keywords: Astrada,payments,card-linking,API client
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: urllib3<3.0.0,>=2.1.0
21
+ Requires-Dist: python-dateutil>=2.8.2
22
+ Requires-Dist: pydantic>=2
23
+ Requires-Dist: typing-extensions>=4.7.1
24
+ Dynamic: license-file
25
+
26
+ # Astrada Python SDK
27
+
28
+ The Python client for the [Astrada API](https://docs.astrada.co): subaccounts, enrollment links,
29
+ card subscriptions, transactions, webhooks, the Banking API and the sandbox simulations, from one
30
+ client object. The SDKs have no card-enrollment methods. Card enrollment happens in the browser with the Unified Enrollment SDK v2 or an enrollment link. If you are an approved direct-API partner and send card data through the generic request method, it passes through your server and your PCI scope applies.
31
+ Python 3.10+ (every Python version its maintainers still support is tested; one is dropped only
32
+ in a major release). API version 2024-02-28.
33
+
34
+ **Start here:** [sign up for a sandbox](https://astrada.co/sandbox) ·
35
+ [Getting Started](https://docs.astrada.co/docs/getting-started) ·
36
+ [Authentication](https://docs.astrada.co/docs/authentication) ·
37
+ [API reference](https://docs.astrada.co/reference)
38
+
39
+ Questions: developer@astrada.co. Bugs and feature requests: [GitHub issues](https://github.com/FidelLimited/astrada-python/issues).
40
+ Security problems: report them privately as [SECURITY.md](https://github.com/FidelLimited/astrada-python/blob/main/SECURITY.md) explains.
41
+
42
+ ## Install
43
+
44
+ ```sh
45
+ pip install astrada
46
+ ```
47
+
48
+ ## Upgrading from 1.x
49
+
50
+ - Install `astrada` from PyPI (`pip install astrada`) and `import astrada`: 1.x was the `astrada_api` package,
51
+ which is gone. Python 3.10 or later is required (1.x allowed 3.9).
52
+ - Make one `astrada.Astrada(...)` client with `environment="sandbox"` or `"production"`; it logs in itself and
53
+ covers the main API, `client.banking` and `client.sandbox`.
54
+ - Methods take the names in the API reference: `get_subaccounts` is `list_subaccounts`, `get_transactions` is
55
+ `list_transactions`, `get_transaction_by_id` is `get_transaction`, `bin_lookup` is `lookup_bin` and
56
+ `card_verification_list` is `list_card_verifications`. The `cardholder_api` module is gone: `get_cardholder` is
57
+ on `client.card`.
58
+ - Models are named for what they hold, not for the status code: `GetSubaccounts200Response` is `SubaccountList`,
59
+ `GetTransactions200Response` is `TransactionList`, `CreateSubaccountRequest` is `SubaccountCreateParams`,
60
+ `CreateWebhookRequest` is `WebhookCreateParams` and `CreateWebhook201Response` is `WebhookCreateResult`.
61
+ - Errors are typed (`NotFoundException`, `RateLimitError`, `ApiConnectionError` and the rest; see "Errors"), and a
62
+ Mastercard `TransactionMessage.date_time` is naive (see "Reading transaction times").
63
+
64
+ Every change is listed in the [releases](https://github.com/FidelLimited/astrada-python/releases) and
65
+ `CHANGELOG.md`.
66
+
67
+ ## First call
68
+
69
+ With the sandbox credentials from your sign-up in `ASTRADA_ACCOUNT_ID`, `ASTRADA_CLIENT_ID` and
70
+ `ASTRADA_CLIENT_SECRET`, list your subaccounts:
71
+
72
+ ```python
73
+ import astrada
74
+
75
+ client = astrada.Astrada(environment="sandbox") # reads the three variables
76
+ for subaccount in client.subaccounts.list_subaccounts(limit=5).embedded.subaccounts:
77
+ print(subaccount.name)
78
+ ```
79
+
80
+ ## Log in
81
+
82
+ Make API credentials in the Astrada dashboard first (see
83
+ [Authentication](https://docs.astrada.co/docs/authentication)). Sandbox and production are separate
84
+ environments with separate credentials, so the client asks which one you mean.
85
+
86
+ ```python
87
+ import os
88
+
89
+ import astrada
90
+
91
+ client = astrada.Astrada(
92
+ account_id=os.environ["ASTRADA_ACCOUNT_ID"],
93
+ client_id=os.environ["ASTRADA_CLIENT_ID"],
94
+ client_secret=os.environ["ASTRADA_CLIENT_SECRET"],
95
+ environment="sandbox", # or "production"
96
+ )
97
+ ```
98
+
99
+ The client logs in on its first call, keeps the token and gets a new one shortly before it expires.
100
+ The card APIs and the Banking API (`client.banking`) share that one login. If you leave out the
101
+ three credentials, the client reads the `ASTRADA_ACCOUNT_ID`, `ASTRADA_CLIENT_ID` and
102
+ `ASTRADA_CLIENT_SECRET` environment variables.
103
+
104
+ If the login is refused (`400` or `401`), the call raises `astrada.AuthenticationError` with the
105
+ reason the login service gave, for example
106
+ `Login failed (401): Invalid client or Invalid client credentials.`, and nothing is sent to the
107
+ API. A login that is rate limited or fails on Astrada's side is retried like other calls, then
108
+ raises `RateLimitError` (`429`) or `ServiceException` (`5xx`), not `AuthenticationError`; a wrong
109
+ `account_id` raises `NotFoundException` (`404`).
110
+
111
+ ## Mint a token for the browser enrollment SDK
112
+
113
+ The Unified Enrollment SDK v2 in your page asks your backend for a token (its `getAccessToken` option). Mint it
114
+ with your **SDK client**: the separate client id and secret Astrada gives you for the browser. Never hand the
115
+ browser a token of your backend client: it would carry every scope the backend holds, writes and `banking:admin`
116
+ included, so `mint_sdk_access_token` refuses the backend client's own `client_id` unless that client calls the sandbox API.
117
+
118
+ The token carries every scope the SDK client holds; the login does not narrow a token on request. List in
119
+ `allowed_scopes` only the scopes the browser calls need, from the [SDK credentials
120
+ table](https://docs.astrada.co/docs/authentication#sdk-credentials): the eight in the sample, plus `cards:read`
121
+ if you want the card lookup and `network-bulk-enrollments:write` or `network-bulk-feeds:write` for bulk
122
+ enrollment requests on admin pages. Never list `banking:admin` or `webhooks:write`, and if your SDK client holds
123
+ any scope the browser does not need, ask Astrada to remove it. If you do not offer bank sign-in, leave out the
124
+ two banking scopes and have them removed too. With `allowed_scopes`, the call raises `UnexpectedScopesError`
125
+ instead of returning a token that carries any scope outside the list (the check covers the scopes the login
126
+ states in its answer); a token missing a listed scope is still returned.
127
+
128
+ The token is not tied to one subaccount: for its five minutes it works on every subaccount of your account, for
129
+ card enrollment and card lookups, with the banking scopes for bank links and bank data, and with the bulk
130
+ enrollment scopes for bulk enrollment requests. Your server decides who gets a token, not what the token reaches,
131
+ so check that the signed-in user may use the subaccount the page opens, and remember that a user who copies the
132
+ token can call the API with it until it expires.
133
+
134
+ Sandbox self sign-up only, never in production: that account has one client for both uses, so its token carries
135
+ every backend scope. There, leave `allowed_scopes` out (the default, None).
136
+
137
+ ```python
138
+ import os
139
+
140
+ token = client.mint_sdk_access_token(
141
+ os.environ["ASTRADA_SDK_CLIENT_ID"],
142
+ os.environ["ASTRADA_SDK_CLIENT_SECRET"],
143
+ allowed_scopes=["subaccounts:read", "card-subscriptions:read", "card-subscriptions:write",
144
+ "card-verifications:read", "card-verifications:write", "enrollment-methods:write",
145
+ "banking:read", "banking:write"], # Example: replace with the scopes the browser calls need
146
+ ) # return this from your backend's token route, as plain text
147
+ ```
148
+
149
+ ## List subaccounts
150
+
151
+ ```python
152
+ page = client.subaccounts.list_subaccounts(limit=2)
153
+ for subaccount in page.embedded.subaccounts:
154
+ print(subaccount.id, subaccount.name)
155
+ ```
156
+
157
+ Every API group is an attribute of the client (`client.subaccounts`, `client.enrollment_links`,
158
+ `client.card_subscription`, `client.transactions`, `client.webhooks` and so on; the full list is
159
+ under [Reference](#reference)). Each method returns a model with typed attributes.
160
+
161
+ To read every page, see [Pagination](#pagination).
162
+
163
+ ## Enroll a card
164
+
165
+ An enrollment link is a hosted page where a cardholder enrolls their card. Create one for a
166
+ subaccount and send its `url` to the cardholder:
167
+
168
+ ```python
169
+ subaccount_id = page.embedded.subaccounts[0].id
170
+
171
+ link = client.enrollment_links.create_enrollment_link(
172
+ astrada.EnrollmentLinkCreateParams(
173
+ subaccount_id=subaccount_id,
174
+ kind="cardholder", # a personal link; "team" makes one link for many people
175
+ )
176
+ )
177
+ print("Send this link:", link.url)
178
+ ```
179
+
180
+ When the cardholder finishes, a card subscription exists for their card (and a
181
+ `cardsubscription.created` webhook is sent, see [Webhooks](#verify-a-webhook)):
182
+
183
+ ```python
184
+ subscriptions = client.card_subscription.list_card_subscriptions(subaccount_id=str(subaccount_id))
185
+ for subscription in subscriptions.embedded.card_subscriptions:
186
+ print(subscription.card_id, subscription.state)
187
+ ```
188
+
189
+ Other ways to enroll (the embedded enrollment SDK, network bulk feeds and bank linking) are
190
+ described in the [enrollment guides](https://docs.astrada.co/docs).
191
+
192
+ ## Find out why a card failed
193
+
194
+ A card whose verification failed has a failed verification with a `failure_reason`: a stable
195
+ `category` to branch on, a `description` you can show the cardholder, and whether a retry can
196
+ work (`retryable`).
197
+
198
+ ```python
199
+ card_id = subscriptions.embedded.card_subscriptions[0].card_id
200
+
201
+ verifications = client.card_verification.list_card_verifications(card_id, state="failed")
202
+ for verification in verifications.embedded.card_verifications:
203
+ reason = verification.failure_reason
204
+ if reason is not None:
205
+ print(reason.category, reason.description, "retryable:", reason.retryable)
206
+ ```
207
+
208
+ ## Simulate activity in the sandbox
209
+
210
+ The sandbox can make test transactions on enrolled cards and simulate network bulk files (see
211
+ [Sandbox API](https://docs.astrada.co/docs/sandbox-api)). Those methods are on `client.sandbox`:
212
+
213
+ ```python
214
+ from astrada.sandbox import SimulateTransactionRequest
215
+
216
+ accepted = client.sandbox.simulate_transaction(
217
+ SimulateTransactionRequest(card_id=card_id, type="authorization", amount=4500)
218
+ )
219
+ print(accepted)
220
+ ```
221
+
222
+ The simulation runs in the background; the transaction then shows up in
223
+ `client.transactions.list_transactions()` and in your webhooks.
224
+
225
+ `client.sandbox` only works on a sandbox client: on a client made with
226
+ `environment="production"` (or with a `base_url` that is not the sandbox API), every
227
+ `client.sandbox` method raises `astrada.SandboxOnlyError` before sending anything, not even the
228
+ login. To send sandbox calls through a proxy or a local mock, mark it:
229
+ `astrada.Astrada(environment="sandbox", base_url="http://localhost:4010", sandbox_base_url=True)`.
230
+
231
+ ## Clear test data in the sandbox
232
+
233
+ `client.sandbox` also has the sandbox-only deletes, for clearing test data between runs:
234
+ `delete_subaccount` (the subaccount and everything under it: bank links, card subscriptions,
235
+ cards, transactions, bulk feeds and webhooks), `delete_card_subscription` and
236
+ `delete_network_bulk_feed`. They cannot be undone. Each returns when the delete has finished, or
237
+ raises `ServiceException` (`502`) when a step failed; calling it again after a failure is safe,
238
+ because finished steps are skipped. The SDK never retries them itself, since a second call while
239
+ the first is still running is not safe. The sandbox API's gateway answers `504` after 29 seconds
240
+ while a longer delete keeps running (the SDK's own 5-minute wait cannot extend that): after a
241
+ `504`, read the resource (`get_subaccount`, `get_card_subscription`, `get_network_bulk_feed`)
242
+ every few seconds: `404` (`NotFoundException`) means the delete finished. A delete runs for at most
243
+ about 5 minutes, so if the resource still answers after 6 minutes, the first delete has stopped part-way
244
+ and calling it again is safe (finished steps are skipped). A `401` is raised as `UnauthorizedException`: this client does not log in again on a
245
+ refused token, so it does not send the delete again either. Production has no delete calls, and
246
+ these raise `astrada.SandboxOnlyError` outside the sandbox.
247
+
248
+ ```python
249
+ client.sandbox.delete_subaccount(subaccount_id)
250
+ ```
251
+
252
+ ## Test bulk enrollment in the sandbox
253
+
254
+ Bulk enrollment enrolls a company's cards from the card network's bulk feed. In the sandbox you
255
+ create the feed as in production, then make the network "deliver" a feed file with
256
+ `client.sandbox.simulate_bulk_feed_file`: `type` is `"vcf"` or `"vbds"` (Visa), `"smartdata"`
257
+ (Mastercard) or `"gl"` (American Express). The simulated cards come from a fixed sandbox test-card
258
+ pool, and each one becomes a card subscription on the feed (see
259
+ [Testing Bulk Enrollment](https://docs.astrada.co/docs/sandbox-bulk-enrollment)).
260
+
261
+ ```python
262
+ feed = client.network_bulk_feeds.create_network_bulk_feed(
263
+ astrada.NetworkBulkFeedCreateParams(
264
+ network="VISA", network_reference="1_123_45_6789", subaccount_id=subaccount_id
265
+ )
266
+ )
267
+
268
+ client.sandbox.simulate_bulk_feed_file(
269
+ type="vcf", network_reference="1_123_45_6789", card_count=3, transactions_per_card=1
270
+ )
271
+
272
+ bulk_cards = client.card_subscription.list_card_subscriptions(network_bulk_feed_id=str(feed.id))
273
+ print(bulk_cards.total_items, "card(s) on the feed so far")
274
+ ```
275
+
276
+ The file is processed in the background, so the cards appear a short while after the call. Each
277
+ of the four file kinds also has its own method (`simulate_bulk_feed_file_vcf` and so on), and the
278
+ same sandbox-only check applies to all of them.
279
+
280
+ ## Verify a webhook
281
+
282
+ Pass the raw request body, the headers and the webhook's `secret` (returned once when you create
283
+ the webhook). `verify_webhook` raises `WebhookVerificationError` if the signature does not match,
284
+ the delivery is more than five minutes old or the body is not JSON. Otherwise it returns a
285
+ `WebhookEvent`: `event.type` is the event type, and `event.data` is a typed model for
286
+ transaction, transaction message, card subscription and cardholder events (a `dict` for the
287
+ others).
288
+
289
+ <!-- standalone -->
290
+ ```python
291
+ import os
292
+
293
+ from flask import Flask, request
294
+
295
+ import astrada
296
+
297
+ app = Flask(__name__)
298
+ # After this many unreadable deliveries of one event, answer 2xx and rely on the stored copy.
299
+ MAX_UNREADABLE_DELIVERIES = 3
300
+
301
+
302
+ def store_unreadable(event: astrada.WebhookEvent, body: bytes) -> int:
303
+ """Replace with your own store (a table keyed by event.id). Save event.id, event.type,
304
+ event.timestamp, the raw body, the time of the check, event.unreadable and
305
+ event.unreadable_messages (so a replay of a partial delivery knows which messages were
306
+ missing), and return how many times this id has been saved, counting this one. Until you
307
+ replace it, it raises, so the handler answers 500 and Astrada delivers the event again."""
308
+ raise NotImplementedError("store_unreadable is not set up (delivery %s)" % event.id)
309
+
310
+
311
+ @app.post("/astrada/webhooks")
312
+ def astrada_webhook():
313
+ body = request.get_data()
314
+ try:
315
+ event = astrada.verify_webhook(body, request.headers, os.environ["ASTRADA_WEBHOOK_SECRET"])
316
+ except astrada.WebhookVerificationError:
317
+ return "", 400 # not from Astrada, or too old: refuse it
318
+ if event.unreadable or event.unreadable_messages:
319
+ # Signed by Astrada (the check passed), but this SDK cannot read the body, or one of a
320
+ # transaction's messages (event.messages has the others). Store it first; answer 2xx only
321
+ # once it is stored.
322
+ try:
323
+ failures = store_unreadable(event, body)
324
+ except Exception as error:
325
+ # The type only: an error from a database driver can include the body it was given.
326
+ print("Unreadable webhook not stored", event.id, type(error).__name__)
327
+ return "", 500 # not stored: Astrada must deliver it again
328
+ print("Unreadable webhook stored", event.id, failures, len(event.unreadable_messages))
329
+ if event.unreadable:
330
+ return "", 204 if failures >= MAX_UNREADABLE_DELIVERIES else 500
331
+ if event.type == "transaction.created" and not event.unreadable:
332
+ transaction = event.data # an astrada.Transaction
333
+ print("New transaction", transaction.id)
334
+ # Record event.id as handled in your store here, so a replay or a repeated delivery can skip it.
335
+ # Answer within 5 seconds; do slow work after answering.
336
+ return "", 204
337
+ ```
338
+
339
+ Answer `400` only for `WebhookVerificationError`. `event.unreadable` means the delivery is signed but this SDK
340
+ cannot read it: store it, then answer `500` so Astrada delivers it again, and answer `2xx` once it is stored and
341
+ has failed `MAX_UNREADABLE_DELIVERIES` times (3 here; choose your own). With only `event.unreadable_messages`, the
342
+ transaction itself was read and handled, so the sample stores the delivery and answers `204`; replay only its
343
+ missing messages later. The stored copy is how you recover the event: after updating the SDK, read each stored
344
+ delivery with `astrada.parse_stored_webhook(body, event_type, id, timestamp)`. It checks no signature (the
345
+ five-minute limit would refuse a stored delivery anyway), so give it only deliveries you stored after the check
346
+ passed, and keep the time of that check with them. Store whether a delivery was partial, so a replay knows which
347
+ part is missing.
348
+ Replay with care: skip a stored delivery whose id you already handled (except a partial delivery, whose
349
+ transaction you handled but whose missing messages you have not), because a retry can succeed once the SDK is
350
+ updated. The stored body is a snapshot: for a transaction, apply it only if its `data.updated_at` is newer than
351
+ your copy's; for other resources, fetch the current state first. (`event.timestamp` is when the delivery was
352
+ sent, so a late retry carries a newer one; do not compare it.) Mark the stored row as handled, or delete it, once
353
+ it is done.
354
+
355
+ Deliveries can repeat: `event.id` is the same on every retry of one event.
356
+
357
+ ## Reading transaction times
358
+
359
+ A transaction message's `date_time` is a `datetime`, and what it holds depends on the card network:
360
+
361
+ - Visa and Amex send UTC (a `Z` in the API): `date_time` is timezone-aware, an exact moment.
362
+ - Mastercard sends the merchant's local date and time with no offset: `date_time` is naive. It is the
363
+ wall-clock time where the card was used, and Astrada does not receive that merchant's time zone, so it is
364
+ not an exact moment. Do not call `.timestamp()` or `.astimezone()` on it (Python would use your server's
365
+ zone), and do not compare or sort it with an aware value (`TypeError`).
366
+ - Some messages carry an end-of-day value rather than the moment they happened: Visa clearings
367
+ (`FINL_ADVC`, `FINL_REQU`) the settlement date at `23:59:59Z`, Visa reversals (`AUTH_ADVC` with a
368
+ negative amount) `23:59:59Z` on the day Astrada received them, Amex clearings the business date at
369
+ `23:59:59Z`. Use the transaction's `transaction_occurrence_date` for the purchase date.
370
+ - For other networks (such as `OPEN_BANKING`) the definition does not say which zone applies: an aware
371
+ value is exact, a naive one is a wall time of unknown zone.
372
+
373
+ To order messages across networks, use `created_date_time`: when Astrada recorded the message, in UTC.
374
+ A `transaction.created` or `transaction.updated` webhook carries a short form of each message in
375
+ `_embedded.messages`; `verify_webhook` gives them as `event.messages`, with `date_time` read the same way.
376
+
377
+ ```python
378
+ message = client.transaction_messages.get_transaction_message("3f2b8c1e-6a4d-4e2f-9b7a-1c5d8e9f0a2b")
379
+ if message.date_time.tzinfo is None:
380
+ print("local time, no zone (the merchant's for Mastercard):", message.date_time.isoformat())
381
+ else:
382
+ print("UTC:", message.date_time.isoformat())
383
+ print("recorded:", message.created_date_time.isoformat())
384
+ ```
385
+
386
+ ## Pagination
387
+
388
+ List methods return one page. `astrada.paginate` walks every page for you and yields the items; it
389
+ asks for the next page only when the loop gets there:
390
+
391
+ ```python
392
+ for subaccount in astrada.paginate(client.subaccounts.list_subaccounts, limit=100):
393
+ print(subaccount.id)
394
+
395
+ for bank_link in astrada.paginate(client.banking.bank_links.list_bank_links):
396
+ print(bank_link.id, bank_link.state)
397
+ ```
398
+
399
+ It works for every `list_*` method, whether the endpoint pages with a cursor or an offset, and
400
+ passes your filters along. `astrada.pagination.pages` yields whole pages instead.
401
+
402
+ ## Errors
403
+
404
+ Every failed call raises a subclass of `astrada.ApiException`. Each one has `status`, `title`,
405
+ `detail`, `code` (when the API sends one), `errors` (the list of problems in a `400`), `body` and
406
+ `headers`.
407
+
408
+ ```python
409
+ try:
410
+ client.subaccounts.get_subaccount("00000000-0000-0000-0000-000000000000")
411
+ except astrada.NotFoundException as e:
412
+ print("Not found:", e.detail)
413
+ except astrada.ApiException as e:
414
+ print("Failed:", e.status, e.title, e.detail)
415
+ ```
416
+
417
+ | Exception | When |
418
+ |---|---|
419
+ | `AuthenticationError` | The login was refused with `400` or `401` (the token endpoint's message is in `detail`); its subclass `UnauthorizedException` is a `401` from the API |
420
+ | `BadRequestException` | `400`: `errors` lists each problem |
421
+ | `ForbiddenException` | `403`: often a scope your API client does not have |
422
+ | `NotFoundException` | `404` |
423
+ | `ConflictException` | `409` |
424
+ | `UnprocessableEntityException` | `422` |
425
+ | `RateLimitError` | `429` after the retries; `retry_after` is the wait the API asked for |
426
+ | `ServiceException` | `5xx` after the retries |
427
+ | `ApiConnectionError` | No answer, or not all of it: the host could not be reached, TLS failed, the call timed out, or the body stopped arriving or was cut off (`status` is 0) |
428
+ | `ScopeRequiredError` | `403` on a Banking API method that needs a scope, most likely one your API client does not have; `required_scope` names it |
429
+ | `SandboxOnlyError` | A `client.sandbox` method, or a sandbox-only path given to `client.request`, on a client that is not set up for the sandbox (nothing was sent) |
430
+ | `UnexpectedScopesError` | `mint_sdk_access_token` with `allowed_scopes`: the token carries other scopes (`extra_scopes`), or the login stated none; the token is not returned |
431
+
432
+ A response with a value this SDK version does not know yet (a new state or event type, say) does
433
+ not fail: the value is kept as a string. Unknown fields are ignored.
434
+
435
+ ## Retries and timeouts
436
+
437
+ Each request waits up to 60 seconds. Calls that are safe to repeat (`GET`, `PUT`, `DELETE`) are
438
+ retried twice after a `429`, `500`, `502`, `503` or `504`, with waits that grow from half a second,
439
+ and the API's `Retry-After` is honoured when it is 60 seconds or less (a longer one ends the
440
+ retries, and the call raises at once); with this default policy a malformed `Retry-After` means
441
+ the usual wait. Connection failures are retried for every call except the sandbox deletes. A
442
+ `POST` or `PATCH` that got an answer is never sent again, and neither are the sandbox deletes (see
443
+ above). The login is retried the same way after a `429`,
444
+ a `5xx` or a timeout. Calls that need a token while one is being requested wait for it, so with
445
+ the defaults a login that keeps timing out can hold them for about three times the timeout; a
446
+ call's own `_request_timeout` does not shorten the login. A body that stops arriving or a
447
+ connection dropped mid-body raises `ApiConnectionError` and is not retried. With a urllib3 `Retry`
448
+ of your own (`retries=Retry(...)`), running out of retries still raises the matching exception
449
+ (such as `RateLimitError`), and the login adds `POST` to its allowed methods; its `Retry-After`
450
+ handling is urllib3's own (a malformed value raises `ApiConnectionError`, and there is no 60-second
451
+ cap).
452
+
453
+ ```python
454
+ patient_client = astrada.Astrada(environment="sandbox", timeout=120, retries=5)
455
+ quiet_client = astrada.Astrada(environment="sandbox", retries=0)
456
+
457
+ # One call with its own timeout, in seconds:
458
+ client.subaccounts.list_subaccounts(_request_timeout=10)
459
+ ```
460
+
461
+ ## Operations that need banking:admin
462
+
463
+ A few Banking API methods (for example `client.banking.bank_links.sync_bank_link` and the bank
464
+ subscription reads) need the `banking:admin` scope. Their reference pages start with "Needs
465
+ banking:admin". If your API client does not have the scope, the API answers `403` and the method
466
+ raises `astrada.ScopeRequiredError`, a subclass of `ForbiddenException`, which names the scope in
467
+ `required_scope`. Ask Astrada to enable it if you need one of these operations. As with any `403`,
468
+ the resource may also not be your account's, so the message names the scope as the likely cause.
469
+
470
+ ```python
471
+ try:
472
+ client.banking.bank_links.sync_bank_link("enrollment_792dcb7d")
473
+ except astrada.ScopeRequiredError as e:
474
+ print(e.operation, "needs", e.required_scope)
475
+ ```
476
+
477
+ ## Calling an endpoint the SDK doesn't wrap
478
+
479
+ If the API has an endpoint this version of the SDK has no method for, call it with `client.request`. It uses the
480
+ client's login, environment and timeouts, and raises the same exceptions (`NotFoundException`, `ApiException` and
481
+ the rest). It retries a GET, PUT or DELETE on the same rules as the rest of the SDK and never sends a POST or
482
+ PATCH twice. Every sandbox-only operation (listed from the sandbox API definition when the SDK is built, such as
483
+ `DELETE /subaccounts/{id}`) and any `/simulate` path get the same sandbox check as `client.sandbox`, and the
484
+ sandbox-only deletes are never retried. The path is normalised once (`.` and `..` resolved, repeated slashes
485
+ dropped; a raw `?`, `#`, `\`, space or control character, or an encoded `/`, `\`, `.`, `?`, `#` or control
486
+ character, refused), and the checks run on the path that is sent. It returns the parsed JSON body, or None for an
487
+ empty one.
488
+
489
+ ```python
490
+ page = client.request("GET", "/cards", query={"limit": 5})
491
+ print(len(page["_embedded"]["cards"]))
492
+ ```
493
+
494
+ ## Testing your code
495
+
496
+ `astrada.testing.MockAstrada` gives you a client whose calls never leave your process. Every
497
+ method answers with the example from the API definition (regenerated with each SDK release, so it
498
+ follows the API), and you can set the answer of any method:
499
+
500
+ ```python
501
+ from astrada.testing import MockAstrada
502
+
503
+ with MockAstrada() as mock:
504
+ mock.respond(
505
+ "get_subaccount", status=404, body={"title": "Not Found", "detail": "No such subaccount"}
506
+ )
507
+ try:
508
+ mock.client.subaccounts.get_subaccount("3f2b8c1e-6a4d-4e2f-9b7a-1c5d8e9f0a2b")
509
+ except astrada.NotFoundException:
510
+ print("handled the 404")
511
+
512
+ page = mock.client.subaccounts.list_subaccounts() # the definition's example
513
+ print(len(page.embedded.subaccounts), "subaccount(s);", mock.calls[-1])
514
+ ```
515
+
516
+ `mock.respond(name, handler=...)` takes a function of the recorded call for answers that depend
517
+ on the request, `mock.calls` lists what was sent, and `mock.refuse_login()` makes the next login
518
+ fail. Pass your own client (`MockAstrada(client)`) to answer for one your code already made.
519
+
520
+ To run a mock HTTP server instead (for a whole app, or to try requests by hand), serve the API
521
+ definition with [Prism](https://github.com/stoplightio/prism):
522
+
523
+ ```sh
524
+ npx @stoplight/prism-cli mock https://raw.githubusercontent.com/FidelLimited/astrada-python/main/test/standin/openapi-main.json
525
+ ```
526
+
527
+ and point a client at it (Prism has no login, so pass any token):
528
+
529
+ ```python
530
+ prism_client = astrada.Astrada(
531
+ environment="sandbox", base_url="http://127.0.0.1:4010", access_token="test"
532
+ )
533
+ ```
534
+
535
+ The Banking API and the sandbox definitions are next to it (`openapi-banking.json`,
536
+ `openapi-sandbox.json`).
537
+
538
+ ## Banking API
539
+
540
+ The Banking API (bank links, bank accounts, bank subscriptions, bank transactions and transaction
541
+ matches) is `client.banking`:
542
+
543
+ ```python
544
+ bank_links = client.banking.bank_links.list_bank_links(limit=10)
545
+ for bank_link in bank_links.items:
546
+ print(bank_link.id, bank_link.state)
547
+ ```
548
+
549
+ ## Reference
550
+
551
+ The full reference, built from the code, is at
552
+ [fidellimited.github.io/astrada-python](https://fidellimited.github.io/astrada-python/astrada.html).
553
+ Each method is also described on the API reference at
554
+ [docs.astrada.co/reference](https://docs.astrada.co/reference).
555
+
556
+ | Client attribute | Method | HTTP request |
557
+ |---|---|---|
558
+ | `client.bin_lookup` | [`lookup_bin`](https://github.com/FidelLimited/astrada-python/blob/main/docs/BinLookupApi.md#lookup_bin) | `GET /bin-lookup` |
559
+ | `client.card` | [`get_card`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardApi.md#get_card) | `GET /cards/{cardId}` |
560
+ | `client.card` | [`get_cardholder`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardApi.md#get_cardholder) | `GET /cards/{cardId}/cardholder` |
561
+ | `client.card` | [`list_cards`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardApi.md#list_cards) | `GET /cards` |
562
+ | `client.card` | [`update_cardholder`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardApi.md#update_cardholder) | `PATCH /cards/{cardId}/cardholder` |
563
+ | `client.card_subscription` | [`get_card_subscription`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardSubscriptionApi.md#get_card_subscription) | `GET /card-subscriptions/{subscriptionId}` |
564
+ | `client.card_subscription` | [`list_card_subscriptions`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardSubscriptionApi.md#list_card_subscriptions) | `GET /card-subscriptions` |
565
+ | `client.card_subscription` | [`update_card_subscription`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardSubscriptionApi.md#update_card_subscription) | `PATCH /card-subscriptions/{subscriptionId}` |
566
+ | `client.card_verification` | [`get_card_verification`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardVerificationApi.md#get_card_verification) | `GET /card-verifications/3ds/{verificationId}` |
567
+ | `client.card_verification` | [`list_card_verifications`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardVerificationApi.md#list_card_verifications) | `GET /card-verifications/3ds` |
568
+ | `client.card_verification` | [`unlock_card_verification_attempts`](https://github.com/FidelLimited/astrada-python/blob/main/docs/CardVerificationApi.md#unlock_card_verification_attempts) | `POST /card-verifications/unlock` |
569
+ | `client.enrollment_links` | [`create_enrollment_link`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentLinksApi.md#create_enrollment_link) | `POST /enrollment-links` |
570
+ | `client.enrollment_links` | [`create_team_link`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentLinksApi.md#create_team_link) | `POST /subaccounts/{subaccountId}/team-link` |
571
+ | `client.enrollment_links` | [`get_enrollment_link`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentLinksApi.md#get_enrollment_link) | `GET /enrollment-links/{linkId}` |
572
+ | `client.enrollment_links` | [`list_enrollment_links`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentLinksApi.md#list_enrollment_links) | `GET /enrollment-links` |
573
+ | `client.enrollment_links` | [`revoke_enrollment_link`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentLinksApi.md#revoke_enrollment_link) | `POST /enrollment-links/{linkId}/revoke` |
574
+ | `client.enrollment_methods` | [`get_enrollment_methods`](https://github.com/FidelLimited/astrada-python/blob/main/docs/EnrollmentMethodsApi.md#get_enrollment_methods) | `POST /enrollment-methods` |
575
+ | `client.network_bulk_enrollments` | [`create_network_bulk_confirmation`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkEnrollmentsApi.md#create_network_bulk_confirmation) | `POST /network-bulk-confirmations` |
576
+ | `client.network_bulk_enrollments` | [`create_network_bulk_enrollment`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkEnrollmentsApi.md#create_network_bulk_enrollment) | `POST /network-bulk-enrollments` |
577
+ | `client.network_bulk_enrollments` | [`get_network_bulk_enrollment`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkEnrollmentsApi.md#get_network_bulk_enrollment) | `GET /network-bulk-enrollments/{networkBulkEnrollmentId}` |
578
+ | `client.network_bulk_enrollments` | [`get_open_network_bulk_enrollment`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkEnrollmentsApi.md#get_open_network_bulk_enrollment) | `GET /network-bulk-enrollments/open` |
579
+ | `client.network_bulk_feeds` | [`create_network_bulk_feed`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkFeedsApi.md#create_network_bulk_feed) | `POST /network-bulk-feeds` |
580
+ | `client.network_bulk_feeds` | [`get_network_bulk_feed`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkFeedsApi.md#get_network_bulk_feed) | `GET /network-bulk-feeds/{networkBulkFeedId}` |
581
+ | `client.network_bulk_feeds` | [`list_network_bulk_feeds`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkFeedsApi.md#list_network_bulk_feeds) | `GET /network-bulk-feeds` |
582
+ | `client.network_bulk_feeds` | [`update_network_bulk_feed`](https://github.com/FidelLimited/astrada-python/blob/main/docs/NetworkBulkFeedsApi.md#update_network_bulk_feed) | `PATCH /network-bulk-feeds/{networkBulkFeedId}` |
583
+ | `client.subaccounts` | [`create_subaccount`](https://github.com/FidelLimited/astrada-python/blob/main/docs/SubaccountsApi.md#create_subaccount) | `POST /subaccounts` |
584
+ | `client.subaccounts` | [`get_subaccount`](https://github.com/FidelLimited/astrada-python/blob/main/docs/SubaccountsApi.md#get_subaccount) | `GET /subaccounts/{subaccountId}` |
585
+ | `client.subaccounts` | [`list_subaccounts`](https://github.com/FidelLimited/astrada-python/blob/main/docs/SubaccountsApi.md#list_subaccounts) | `GET /subaccounts` |
586
+ | `client.subaccounts` | [`update_subaccount`](https://github.com/FidelLimited/astrada-python/blob/main/docs/SubaccountsApi.md#update_subaccount) | `PATCH /subaccounts/{subaccountId}` |
587
+ | `client.transaction_messages` | [`get_raw_transaction_message`](https://github.com/FidelLimited/astrada-python/blob/main/docs/TransactionMessagesApi.md#get_raw_transaction_message) | `GET /transaction-messages/{transactionMessageId}/raw` |
588
+ | `client.transaction_messages` | [`get_transaction_message`](https://github.com/FidelLimited/astrada-python/blob/main/docs/TransactionMessagesApi.md#get_transaction_message) | `GET /transaction-messages/{transactionMessageId}` |
589
+ | `client.transactions` | [`get_transaction`](https://github.com/FidelLimited/astrada-python/blob/main/docs/TransactionsApi.md#get_transaction) | `GET /transactions/{transactionId}` |
590
+ | `client.transactions` | [`list_transactions`](https://github.com/FidelLimited/astrada-python/blob/main/docs/TransactionsApi.md#list_transactions) | `GET /transactions` |
591
+ | `client.webhooks` | [`create_webhook`](https://github.com/FidelLimited/astrada-python/blob/main/docs/WebhooksApi.md#create_webhook) | `POST /webhooks` |
592
+ | `client.webhooks` | [`delete_webhook`](https://github.com/FidelLimited/astrada-python/blob/main/docs/WebhooksApi.md#delete_webhook) | `DELETE /webhooks/{webhookId}` |
593
+ | `client.webhooks` | [`get_webhook`](https://github.com/FidelLimited/astrada-python/blob/main/docs/WebhooksApi.md#get_webhook) | `GET /webhooks/{webhookId}` |
594
+ | `client.webhooks` | [`list_webhooks`](https://github.com/FidelLimited/astrada-python/blob/main/docs/WebhooksApi.md#list_webhooks) | `GET /webhooks` |
595
+ | `client.webhooks` | [`update_webhook`](https://github.com/FidelLimited/astrada-python/blob/main/docs/WebhooksApi.md#update_webhook) | `PATCH /webhooks/{webhookId}` |
596
+
597
+
598
+ Banking methods (`client.banking.<group>`) are listed in
599
+ [docs/banking/README.md](https://github.com/FidelLimited/astrada-python/blob/main/docs/banking/README.md), and the
600
+ sandbox methods (`client.sandbox`) in
601
+ [docs/sandbox/README.md](https://github.com/FidelLimited/astrada-python/blob/main/docs/sandbox/README.md).
602
+
603
+ ## Versions
604
+
605
+ Releases follow semantic versioning; [CHANGELOG.md](https://github.com/FidelLimited/astrada-python/blob/main/CHANGELOG.md)
606
+ lists what each one changed. `astrada.__version__` is the installed version, and every request
607
+ sends it in the `User-Agent` header (`astrada-python/<version>`).