post-for-me 0.1.0.pre.alpha.3

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 (158) hide show
  1. checksums.yaml +7 -0
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +32 -0
  4. data/README.md +265 -0
  5. data/SECURITY.md +27 -0
  6. data/lib/post_for_me/client.rb +86 -0
  7. data/lib/post_for_me/errors.rb +214 -0
  8. data/lib/post_for_me/file_part.rb +55 -0
  9. data/lib/post_for_me/internal/transport/base_client.rb +563 -0
  10. data/lib/post_for_me/internal/transport/pooled_net_requester.rb +209 -0
  11. data/lib/post_for_me/internal/type/array_of.rb +168 -0
  12. data/lib/post_for_me/internal/type/base_model.rb +537 -0
  13. data/lib/post_for_me/internal/type/base_page.rb +55 -0
  14. data/lib/post_for_me/internal/type/boolean.rb +77 -0
  15. data/lib/post_for_me/internal/type/converter.rb +327 -0
  16. data/lib/post_for_me/internal/type/enum.rb +131 -0
  17. data/lib/post_for_me/internal/type/file_input.rb +108 -0
  18. data/lib/post_for_me/internal/type/hash_of.rb +188 -0
  19. data/lib/post_for_me/internal/type/request_parameters.rb +42 -0
  20. data/lib/post_for_me/internal/type/union.rb +237 -0
  21. data/lib/post_for_me/internal/type/unknown.rb +81 -0
  22. data/lib/post_for_me/internal/util.rb +914 -0
  23. data/lib/post_for_me/internal.rb +20 -0
  24. data/lib/post_for_me/models/create_social_post.rb +558 -0
  25. data/lib/post_for_me/models/media_create_upload_url_params.rb +14 -0
  26. data/lib/post_for_me/models/media_create_upload_url_response.rb +25 -0
  27. data/lib/post_for_me/models/social_account.rb +110 -0
  28. data/lib/post_for_me/models/social_account_create_auth_url_params.rb +109 -0
  29. data/lib/post_for_me/models/social_account_create_auth_url_response.rb +25 -0
  30. data/lib/post_for_me/models/social_account_disconnect_params.rb +14 -0
  31. data/lib/post_for_me/models/social_account_disconnect_response.rb +109 -0
  32. data/lib/post_for_me/models/social_account_list_params.rb +69 -0
  33. data/lib/post_for_me/models/social_account_list_response.rb +58 -0
  34. data/lib/post_for_me/models/social_account_retrieve_params.rb +14 -0
  35. data/lib/post_for_me/models/social_account_update_params.rb +30 -0
  36. data/lib/post_for_me/models/social_post.rb +114 -0
  37. data/lib/post_for_me/models/social_post_create_params.rb +14 -0
  38. data/lib/post_for_me/models/social_post_delete_params.rb +14 -0
  39. data/lib/post_for_me/models/social_post_delete_response.rb +17 -0
  40. data/lib/post_for_me/models/social_post_list_params.rb +87 -0
  41. data/lib/post_for_me/models/social_post_list_response.rb +58 -0
  42. data/lib/post_for_me/models/social_post_result.rb +87 -0
  43. data/lib/post_for_me/models/social_post_result_list_params.rb +51 -0
  44. data/lib/post_for_me/models/social_post_result_list_response.rb +58 -0
  45. data/lib/post_for_me/models/social_post_result_retrieve_params.rb +14 -0
  46. data/lib/post_for_me/models/social_post_retrieve_params.rb +14 -0
  47. data/lib/post_for_me/models/social_post_update_params.rb +14 -0
  48. data/lib/post_for_me/models/tiktok_configuration.rb +88 -0
  49. data/lib/post_for_me/models.rb +77 -0
  50. data/lib/post_for_me/request_options.rb +77 -0
  51. data/lib/post_for_me/resources/media.rb +94 -0
  52. data/lib/post_for_me/resources/social_accounts.rb +143 -0
  53. data/lib/post_for_me/resources/social_post_results.rb +65 -0
  54. data/lib/post_for_me/resources/social_posts.rb +164 -0
  55. data/lib/post_for_me/version.rb +5 -0
  56. data/lib/post_for_me.rb +82 -0
  57. data/manifest.yaml +15 -0
  58. data/rbi/post_for_me/client.rbi +58 -0
  59. data/rbi/post_for_me/errors.rbi +178 -0
  60. data/rbi/post_for_me/file_part.rbi +37 -0
  61. data/rbi/post_for_me/internal/transport/base_client.rbi +294 -0
  62. data/rbi/post_for_me/internal/transport/pooled_net_requester.rbi +79 -0
  63. data/rbi/post_for_me/internal/type/array_of.rbi +104 -0
  64. data/rbi/post_for_me/internal/type/base_model.rbi +304 -0
  65. data/rbi/post_for_me/internal/type/base_page.rbi +42 -0
  66. data/rbi/post_for_me/internal/type/boolean.rbi +58 -0
  67. data/rbi/post_for_me/internal/type/converter.rbi +216 -0
  68. data/rbi/post_for_me/internal/type/enum.rbi +82 -0
  69. data/rbi/post_for_me/internal/type/file_input.rbi +59 -0
  70. data/rbi/post_for_me/internal/type/hash_of.rbi +104 -0
  71. data/rbi/post_for_me/internal/type/request_parameters.rbi +29 -0
  72. data/rbi/post_for_me/internal/type/union.rbi +128 -0
  73. data/rbi/post_for_me/internal/type/unknown.rbi +58 -0
  74. data/rbi/post_for_me/internal/util.rbi +487 -0
  75. data/rbi/post_for_me/internal.rbi +18 -0
  76. data/rbi/post_for_me/models/create_social_post.rbi +1128 -0
  77. data/rbi/post_for_me/models/media_create_upload_url_params.rbi +30 -0
  78. data/rbi/post_for_me/models/media_create_upload_url_response.rbi +38 -0
  79. data/rbi/post_for_me/models/social_account.rbi +139 -0
  80. data/rbi/post_for_me/models/social_account_create_auth_url_params.rbi +260 -0
  81. data/rbi/post_for_me/models/social_account_create_auth_url_response.rbi +36 -0
  82. data/rbi/post_for_me/models/social_account_disconnect_params.rbi +30 -0
  83. data/rbi/post_for_me/models/social_account_disconnect_response.rbi +156 -0
  84. data/rbi/post_for_me/models/social_account_list_params.rbi +112 -0
  85. data/rbi/post_for_me/models/social_account_list_response.rbi +107 -0
  86. data/rbi/post_for_me/models/social_account_retrieve_params.rbi +30 -0
  87. data/rbi/post_for_me/models/social_account_update_params.rbi +60 -0
  88. data/rbi/post_for_me/models/social_post.rbi +142 -0
  89. data/rbi/post_for_me/models/social_post_create_params.rbi +27 -0
  90. data/rbi/post_for_me/models/social_post_delete_params.rbi +27 -0
  91. data/rbi/post_for_me/models/social_post_delete_response.rbi +30 -0
  92. data/rbi/post_for_me/models/social_post_list_params.rbi +207 -0
  93. data/rbi/post_for_me/models/social_post_list_response.rbi +107 -0
  94. data/rbi/post_for_me/models/social_post_result.rbi +130 -0
  95. data/rbi/post_for_me/models/social_post_result_list_params.rbi +86 -0
  96. data/rbi/post_for_me/models/social_post_result_list_response.rbi +107 -0
  97. data/rbi/post_for_me/models/social_post_result_retrieve_params.rbi +30 -0
  98. data/rbi/post_for_me/models/social_post_retrieve_params.rbi +30 -0
  99. data/rbi/post_for_me/models/social_post_update_params.rbi +27 -0
  100. data/rbi/post_for_me/models/tiktok_configuration.rbi +109 -0
  101. data/rbi/post_for_me/models.rbi +42 -0
  102. data/rbi/post_for_me/request_options.rbi +59 -0
  103. data/rbi/post_for_me/resources/media.rbi +83 -0
  104. data/rbi/post_for_me/resources/social_accounts.rbi +112 -0
  105. data/rbi/post_for_me/resources/social_post_results.rbi +51 -0
  106. data/rbi/post_for_me/resources/social_posts.rbi +160 -0
  107. data/rbi/post_for_me/version.rbi +5 -0
  108. data/sig/post_for_me/client.rbs +32 -0
  109. data/sig/post_for_me/errors.rbs +110 -0
  110. data/sig/post_for_me/file_part.rbs +21 -0
  111. data/sig/post_for_me/internal/transport/base_client.rbs +131 -0
  112. data/sig/post_for_me/internal/transport/pooled_net_requester.rbs +45 -0
  113. data/sig/post_for_me/internal/type/array_of.rbs +48 -0
  114. data/sig/post_for_me/internal/type/base_model.rbs +102 -0
  115. data/sig/post_for_me/internal/type/base_page.rbs +24 -0
  116. data/sig/post_for_me/internal/type/boolean.rbs +26 -0
  117. data/sig/post_for_me/internal/type/converter.rbs +79 -0
  118. data/sig/post_for_me/internal/type/enum.rbs +32 -0
  119. data/sig/post_for_me/internal/type/file_input.rbs +25 -0
  120. data/sig/post_for_me/internal/type/hash_of.rbs +48 -0
  121. data/sig/post_for_me/internal/type/request_parameters.rbs +19 -0
  122. data/sig/post_for_me/internal/type/union.rbs +52 -0
  123. data/sig/post_for_me/internal/type/unknown.rbs +26 -0
  124. data/sig/post_for_me/internal/util.rbs +185 -0
  125. data/sig/post_for_me/internal.rbs +9 -0
  126. data/sig/post_for_me/models/create_social_post.rbs +398 -0
  127. data/sig/post_for_me/models/media_create_upload_url_params.rbs +15 -0
  128. data/sig/post_for_me/models/media_create_upload_url_response.rbs +16 -0
  129. data/sig/post_for_me/models/social_account.rbs +81 -0
  130. data/sig/post_for_me/models/social_account_create_auth_url_params.rbs +105 -0
  131. data/sig/post_for_me/models/social_account_create_auth_url_response.rbs +16 -0
  132. data/sig/post_for_me/models/social_account_disconnect_params.rbs +15 -0
  133. data/sig/post_for_me/models/social_account_disconnect_response.rbs +80 -0
  134. data/sig/post_for_me/models/social_account_list_params.rbs +63 -0
  135. data/sig/post_for_me/models/social_account_list_response.rbs +51 -0
  136. data/sig/post_for_me/models/social_account_retrieve_params.rbs +15 -0
  137. data/sig/post_for_me/models/social_account_update_params.rbs +32 -0
  138. data/sig/post_for_me/models/social_post.rbs +83 -0
  139. data/sig/post_for_me/models/social_post_create_params.rbs +15 -0
  140. data/sig/post_for_me/models/social_post_delete_params.rbs +15 -0
  141. data/sig/post_for_me/models/social_post_delete_response.rbs +13 -0
  142. data/sig/post_for_me/models/social_post_list_params.rbs +100 -0
  143. data/sig/post_for_me/models/social_post_list_response.rbs +51 -0
  144. data/sig/post_for_me/models/social_post_result.rbs +66 -0
  145. data/sig/post_for_me/models/social_post_result_list_params.rbs +49 -0
  146. data/sig/post_for_me/models/social_post_result_list_response.rbs +51 -0
  147. data/sig/post_for_me/models/social_post_result_retrieve_params.rbs +15 -0
  148. data/sig/post_for_me/models/social_post_retrieve_params.rbs +15 -0
  149. data/sig/post_for_me/models/social_post_update_params.rbs +15 -0
  150. data/sig/post_for_me/models/tiktok_configuration.rbs +65 -0
  151. data/sig/post_for_me/models.rbs +37 -0
  152. data/sig/post_for_me/request_options.rbs +34 -0
  153. data/sig/post_for_me/resources/media.rbs +11 -0
  154. data/sig/post_for_me/resources/social_accounts.rbs +40 -0
  155. data/sig/post_for_me/resources/social_post_results.rbs +20 -0
  156. data/sig/post_for_me/resources/social_posts.rbs +51 -0
  157. data/sig/post_for_me/version.rbs +3 -0
  158. metadata +215 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a54822869ec4817b44abd2752c33beefe76215c885a9dc91de64700d28b2729d
4
+ data.tar.gz: 355f75deeef86f2649baded79196dcaace4bdf17cbb5ab1bc0cacaed5162f898
5
+ SHA512:
6
+ metadata.gz: 4ad40151b045911be597d76e518c7e838766fbc5041cc112be400cff7642f8b3ecf74b140cd8b4657fa04201200e78668def1962814ccf78ddf81f608e27d0af
7
+ data.tar.gz: 8d662e7acfd4f8af2398c9d53795800958af7b387bced55b35f187f8b928b67ed7c99ba820e9748a33031f23ec2c4a70d7d00740b12cfd9e4c0437fb1532fd32
data/.ignore ADDED
@@ -0,0 +1,2 @@
1
+ rbi/*
2
+ sig/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0-alpha.3 (2025-08-14)
4
+
5
+ Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
6
+
7
+ ## 0.1.0-alpha.2 (2025-08-14)
8
+
9
+ Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
10
+
11
+ ### Features
12
+
13
+ * **api:** update via SDK Studio ([e6dcd18](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/e6dcd18301dfba1f3599c190d9fe0122e13f5795))
14
+
15
+ ## 0.1.0-alpha.1 (2025-08-13)
16
+
17
+ Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/DayMoonDevelopment/post-for-me-ruby/compare/v0.0.1-alpha.0...v0.1.0-alpha.1)
18
+
19
+ ### Features
20
+
21
+ * **api:** update via SDK Studio ([ba84c36](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/ba84c363df972115536055a856fc88018bd100a1))
22
+
23
+
24
+ ### Chores
25
+
26
+ * collect metadata from type DSL ([332df92](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/332df92f64a5c4c4a785fd4f0fbb3592e44a76b1))
27
+ * configure new SDK language ([9985a2e](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/9985a2e4959261f12d25399c53a185b6cf7f899a))
28
+ * **internal:** codegen related update ([fb0d2f4](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/fb0d2f491fb6ecfd9228f17b7dbacfc058861b65))
29
+ * **internal:** increase visibility of internal helper method ([785e851](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/785e851acf28360a16f0ea52908f2f5e30a9328f))
30
+ * **internal:** update comment in script ([acaa0a0](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/acaa0a02d1cd0322c46f149988d2465150c95ca7))
31
+ * update @stainless-api/prism-cli to v5.15.0 ([5037c70](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/5037c7051dd04812b7d0ddc48b32ab3df66c3d86))
32
+ * update SDK settings ([55d0356](https://github.com/DayMoonDevelopment/post-for-me-ruby/commit/55d0356920869865280bc1d4e8228c27ab6e871f))
data/README.md ADDED
@@ -0,0 +1,265 @@
1
+ # Post For Me Ruby API library
2
+
3
+ The Post For Me Ruby library provides convenient access to the Post For Me REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/DayMoonDevelopment/post-for-me-ruby#Sorbet) for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
4
+
5
+ It is generated with [Stainless](https://www.stainless.com/).
6
+
7
+ ## Documentation
8
+
9
+ Documentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/post-for-me).
10
+
11
+ The REST API documentation can be found on [api.postforme.dev](https://api.postforme.dev/docs).
12
+
13
+ ## Installation
14
+
15
+ To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
16
+
17
+ <!-- x-release-please-start-version -->
18
+
19
+ ```ruby
20
+ gem "post-for-me", "~> 0.1.0.pre.alpha.3"
21
+ ```
22
+
23
+ <!-- x-release-please-end -->
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require "bundler/setup"
29
+ require "post_for_me"
30
+
31
+ post_for_me = PostForMe::Client.new(
32
+ api_key: ENV["POST_FOR_ME_API_KEY"] # This is the default and can be omitted
33
+ )
34
+
35
+ social_post = post_for_me.social_posts.create(
36
+ caption: "My first post!",
37
+ social_accounts: ["sa_1234"],
38
+ media: [{url: "https://picsum.photos/1080"}]
39
+ )
40
+
41
+ puts(social_post.id)
42
+ ```
43
+
44
+ ### Handling errors
45
+
46
+ When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `PostForMe::Errors::APIError` will be thrown:
47
+
48
+ ```ruby
49
+ begin
50
+ social_post = post_for_me.social_posts.create(
51
+ caption: "My first post!",
52
+ social_accounts: ["sa_1234"],
53
+ media: [{url: "https://picsum.photos/1080"}]
54
+ )
55
+ rescue PostForMe::Errors::APIConnectionError => e
56
+ puts("The server could not be reached")
57
+ puts(e.cause) # an underlying Exception, likely raised within `net/http`
58
+ rescue PostForMe::Errors::RateLimitError => e
59
+ puts("A 429 status code was received; we should back off a bit.")
60
+ rescue PostForMe::Errors::APIStatusError => e
61
+ puts("Another non-200-range status code was received")
62
+ puts(e.status)
63
+ end
64
+ ```
65
+
66
+ Error codes are as follows:
67
+
68
+ | Cause | Error Type |
69
+ | ---------------- | -------------------------- |
70
+ | HTTP 400 | `BadRequestError` |
71
+ | HTTP 401 | `AuthenticationError` |
72
+ | HTTP 403 | `PermissionDeniedError` |
73
+ | HTTP 404 | `NotFoundError` |
74
+ | HTTP 409 | `ConflictError` |
75
+ | HTTP 422 | `UnprocessableEntityError` |
76
+ | HTTP 429 | `RateLimitError` |
77
+ | HTTP >= 500 | `InternalServerError` |
78
+ | Other HTTP error | `APIStatusError` |
79
+ | Timeout | `APITimeoutError` |
80
+ | Network error | `APIConnectionError` |
81
+
82
+ ### Retries
83
+
84
+ Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
85
+
86
+ Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
87
+
88
+ You can use the `max_retries` option to configure or disable this:
89
+
90
+ ```ruby
91
+ # Configure the default for all requests:
92
+ post_for_me = PostForMe::Client.new(
93
+ max_retries: 0 # default is 2
94
+ )
95
+
96
+ # Or, configure per-request:
97
+ post_for_me.social_posts.create(
98
+ caption: "My first post!",
99
+ social_accounts: ["sa_1234"],
100
+ media: [{url: "https://picsum.photos/1080"}],
101
+ request_options: {max_retries: 5}
102
+ )
103
+ ```
104
+
105
+ ### Timeouts
106
+
107
+ By default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:
108
+
109
+ ```ruby
110
+ # Configure the default for all requests:
111
+ post_for_me = PostForMe::Client.new(
112
+ timeout: nil # default is 60
113
+ )
114
+
115
+ # Or, configure per-request:
116
+ post_for_me.social_posts.create(
117
+ caption: "My first post!",
118
+ social_accounts: ["sa_1234"],
119
+ media: [{url: "https://picsum.photos/1080"}],
120
+ request_options: {timeout: 5}
121
+ )
122
+ ```
123
+
124
+ On timeout, `PostForMe::Errors::APITimeoutError` is raised.
125
+
126
+ Note that requests that time out are retried by default.
127
+
128
+ ## Advanced concepts
129
+
130
+ ### BaseModel
131
+
132
+ All parameter and response objects inherit from `PostForMe::Internal::Type::BaseModel`, which provides several conveniences, including:
133
+
134
+ 1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.
135
+
136
+ 2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
137
+
138
+ 3. Both instances and the classes themselves can be pretty-printed.
139
+
140
+ 4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.
141
+
142
+ ### Making custom or undocumented requests
143
+
144
+ #### Undocumented properties
145
+
146
+ You can send undocumented parameters to any endpoint, and read undocumented response properties, like so:
147
+
148
+ Note: the `extra_` parameters of the same name overrides the documented parameters.
149
+
150
+ ```ruby
151
+ social_post =
152
+ post_for_me.social_posts.create(
153
+ caption: "My first post!",
154
+ social_accounts: ["sa_1234"],
155
+ media: [{url: "https://picsum.photos/1080"}],
156
+ request_options: {
157
+ extra_query: {my_query_parameter: value},
158
+ extra_body: {my_body_parameter: value},
159
+ extra_headers: {"my-header": value}
160
+ }
161
+ )
162
+
163
+ puts(social_post[:my_undocumented_property])
164
+ ```
165
+
166
+ #### Undocumented request params
167
+
168
+ If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.
169
+
170
+ #### Undocumented endpoints
171
+
172
+ To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:
173
+
174
+ ```ruby
175
+ response = client.request(
176
+ method: :post,
177
+ path: '/undocumented/endpoint',
178
+ query: {"dog": "woof"},
179
+ headers: {"useful-header": "interesting-value"},
180
+ body: {"hello": "world"}
181
+ )
182
+ ```
183
+
184
+ ### Concurrency & connection pooling
185
+
186
+ The `PostForMe::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
187
+
188
+ Each instance of `PostForMe::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
189
+
190
+ When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
191
+
192
+ Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
193
+
194
+ ## Sorbet
195
+
196
+ This library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.
197
+
198
+ You can provide typesafe request parameters like so:
199
+
200
+ ```ruby
201
+ post_for_me.social_posts.create(
202
+ caption: "My first post!",
203
+ social_accounts: ["sa_1234"],
204
+ media: [PostForMe::CreateSocialPost::Media.new(url: "https://picsum.photos/1080")]
205
+ )
206
+ ```
207
+
208
+ Or, equivalently:
209
+
210
+ ```ruby
211
+ # Hashes work, but are not typesafe:
212
+ post_for_me.social_posts.create(
213
+ caption: "My first post!",
214
+ social_accounts: ["sa_1234"],
215
+ media: [{url: "https://picsum.photos/1080"}]
216
+ )
217
+
218
+ # You can also splat a full Params class:
219
+ params = PostForMe::SocialPostCreateParams.new(
220
+ caption: "My first post!",
221
+ social_accounts: ["sa_1234"],
222
+ media: [PostForMe::CreateSocialPost::Media.new(url: "https://picsum.photos/1080")]
223
+ )
224
+ post_for_me.social_posts.create(**params)
225
+ ```
226
+
227
+ ### Enums
228
+
229
+ Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
230
+
231
+ ```ruby
232
+ # :draft
233
+ puts(PostForMe::SocialPost::Status::DRAFT)
234
+
235
+ # Revealed type: `T.all(PostForMe::SocialPost::Status, Symbol)`
236
+ T.reveal_type(PostForMe::SocialPost::Status::DRAFT)
237
+ ```
238
+
239
+ Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
240
+
241
+ ```ruby
242
+ PostForMe::SocialPost.new(
243
+ status: PostForMe::SocialPost::Status::DRAFT,
244
+ # …
245
+ )
246
+
247
+ PostForMe::SocialPost.new(
248
+ status: :draft,
249
+ # …
250
+ )
251
+ ```
252
+
253
+ ## Versioning
254
+
255
+ This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
256
+
257
+ This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
258
+
259
+ ## Requirements
260
+
261
+ Ruby 3.2.0 or higher.
262
+
263
+ ## Contributing
264
+
265
+ See [the contributing documentation](https://github.com/DayMoonDevelopment/post-for-me-ruby/tree/main/CONTRIBUTING.md).
data/SECURITY.md ADDED
@@ -0,0 +1,27 @@
1
+ # Security Policy
2
+
3
+ ## Reporting Security Issues
4
+
5
+ This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
6
+
7
+ To report a security issue, please contact the Stainless team at security@stainless.com.
8
+
9
+ ## Responsible Disclosure
10
+
11
+ We appreciate the efforts of security researchers and individuals who help us maintain the security of
12
+ SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible
13
+ disclosure practices by allowing us a reasonable amount of time to investigate and address the issue
14
+ before making any information public.
15
+
16
+ ## Reporting Non-SDK Related Security Issues
17
+
18
+ If you encounter security issues that are not directly related to SDKs but pertain to the services
19
+ or products provided by Post For Me, please follow the respective company's security reporting guidelines.
20
+
21
+ ### Post For Me Terms and Policies
22
+
23
+ Please contact postforme@daymoon.dev for any questions or concerns regarding the security of our services.
24
+
25
+ ---
26
+
27
+ Thank you for helping us keep the SDKs and systems they interact with secure.
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PostForMe
4
+ class Client < PostForMe::Internal::Transport::BaseClient
5
+ # Default max number of retries to attempt after a failed retryable request.
6
+ DEFAULT_MAX_RETRIES = 2
7
+
8
+ # Default per-request timeout.
9
+ DEFAULT_TIMEOUT_IN_SECONDS = 60.0
10
+
11
+ # Default initial retry delay in seconds.
12
+ # Overall delay is calculated using exponential backoff + jitter.
13
+ DEFAULT_INITIAL_RETRY_DELAY = 0.5
14
+
15
+ # Default max retry delay in seconds.
16
+ DEFAULT_MAX_RETRY_DELAY = 8.0
17
+
18
+ # @return [String]
19
+ attr_reader :api_key
20
+
21
+ # @return [PostForMe::Resources::Media]
22
+ attr_reader :media
23
+
24
+ # @return [PostForMe::Resources::SocialPosts]
25
+ attr_reader :social_posts
26
+
27
+ # @return [PostForMe::Resources::SocialPostResults]
28
+ attr_reader :social_post_results
29
+
30
+ # @return [PostForMe::Resources::SocialAccounts]
31
+ attr_reader :social_accounts
32
+
33
+ # @api private
34
+ #
35
+ # @return [Hash{String=>String}]
36
+ private def auth_headers
37
+ return {} if @api_key.nil?
38
+
39
+ {"authorization" => "Bearer #{@api_key}"}
40
+ end
41
+
42
+ # Creates and returns a new client for interacting with the API.
43
+ #
44
+ # @param api_key [String, nil] Defaults to `ENV["POST_FOR_ME_API_KEY"]`
45
+ #
46
+ # @param base_url [String, nil] Override the default base URL for the API, e.g.,
47
+ # `"https://api.example.com/v2/"`. Defaults to `ENV["POST_FOR_ME_BASE_URL"]`
48
+ #
49
+ # @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
50
+ #
51
+ # @param timeout [Float]
52
+ #
53
+ # @param initial_retry_delay [Float]
54
+ #
55
+ # @param max_retry_delay [Float]
56
+ def initialize(
57
+ api_key: ENV["POST_FOR_ME_API_KEY"],
58
+ base_url: ENV["POST_FOR_ME_BASE_URL"],
59
+ max_retries: self.class::DEFAULT_MAX_RETRIES,
60
+ timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
61
+ initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
62
+ max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
63
+ )
64
+ base_url ||= "https://api.postforme.dev"
65
+
66
+ if api_key.nil?
67
+ raise ArgumentError.new("api_key is required, and can be set via environ: \"POST_FOR_ME_API_KEY\"")
68
+ end
69
+
70
+ @api_key = api_key.to_s
71
+
72
+ super(
73
+ base_url: base_url,
74
+ timeout: timeout,
75
+ max_retries: max_retries,
76
+ initial_retry_delay: initial_retry_delay,
77
+ max_retry_delay: max_retry_delay
78
+ )
79
+
80
+ @media = PostForMe::Resources::Media.new(client: self)
81
+ @social_posts = PostForMe::Resources::SocialPosts.new(client: self)
82
+ @social_post_results = PostForMe::Resources::SocialPostResults.new(client: self)
83
+ @social_accounts = PostForMe::Resources::SocialAccounts.new(client: self)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,214 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PostForMe
4
+ module Errors
5
+ class Error < StandardError
6
+ # @!attribute cause
7
+ #
8
+ # @return [StandardError, nil]
9
+ end
10
+
11
+ class ConversionError < PostForMe::Errors::Error
12
+ # @return [StandardError, nil]
13
+ def cause = @cause.nil? ? super : @cause
14
+
15
+ # @api private
16
+ #
17
+ # @param on [Class<StandardError>]
18
+ # @param method [Symbol]
19
+ # @param target [Object]
20
+ # @param value [Object]
21
+ # @param cause [StandardError, nil]
22
+ def initialize(on:, method:, target:, value:, cause: nil)
23
+ cls = on.name.split("::").last
24
+
25
+ message = [
26
+ "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.",
27
+ "To get the unparsed API response, use #{cls}[#{method.inspect}].",
28
+ cause && "Cause: #{cause.message}"
29
+ ].filter(&:itself).join(" ")
30
+
31
+ @cause = cause
32
+ super(message)
33
+ end
34
+ end
35
+
36
+ class APIError < PostForMe::Errors::Error
37
+ # @return [URI::Generic]
38
+ attr_accessor :url
39
+
40
+ # @return [Integer, nil]
41
+ attr_accessor :status
42
+
43
+ # @return [Object, nil]
44
+ attr_accessor :body
45
+
46
+ # @api private
47
+ #
48
+ # @param url [URI::Generic]
49
+ # @param status [Integer, nil]
50
+ # @param body [Object, nil]
51
+ # @param request [nil]
52
+ # @param response [nil]
53
+ # @param message [String, nil]
54
+ def initialize(url:, status: nil, body: nil, request: nil, response: nil, message: nil)
55
+ @url = url
56
+ @status = status
57
+ @body = body
58
+ @request = request
59
+ @response = response
60
+ super(message)
61
+ end
62
+ end
63
+
64
+ class APIConnectionError < PostForMe::Errors::APIError
65
+ # @!attribute status
66
+ #
67
+ # @return [nil]
68
+
69
+ # @!attribute body
70
+ #
71
+ # @return [nil]
72
+
73
+ # @api private
74
+ #
75
+ # @param url [URI::Generic]
76
+ # @param status [nil]
77
+ # @param body [nil]
78
+ # @param request [nil]
79
+ # @param response [nil]
80
+ # @param message [String, nil]
81
+ def initialize(
82
+ url:,
83
+ status: nil,
84
+ body: nil,
85
+ request: nil,
86
+ response: nil,
87
+ message: "Connection error."
88
+ )
89
+ super
90
+ end
91
+ end
92
+
93
+ class APITimeoutError < PostForMe::Errors::APIConnectionError
94
+ # @api private
95
+ #
96
+ # @param url [URI::Generic]
97
+ # @param status [nil]
98
+ # @param body [nil]
99
+ # @param request [nil]
100
+ # @param response [nil]
101
+ # @param message [String, nil]
102
+ def initialize(
103
+ url:,
104
+ status: nil,
105
+ body: nil,
106
+ request: nil,
107
+ response: nil,
108
+ message: "Request timed out."
109
+ )
110
+ super
111
+ end
112
+ end
113
+
114
+ class APIStatusError < PostForMe::Errors::APIError
115
+ # @api private
116
+ #
117
+ # @param url [URI::Generic]
118
+ # @param status [Integer]
119
+ # @param body [Object, nil]
120
+ # @param request [nil]
121
+ # @param response [nil]
122
+ # @param message [String, nil]
123
+ #
124
+ # @return [self]
125
+ def self.for(url:, status:, body:, request:, response:, message: nil)
126
+ kwargs = {
127
+ url: url,
128
+ status: status,
129
+ body: body,
130
+ request: request,
131
+ response: response,
132
+ message: message
133
+ }
134
+
135
+ case status
136
+ in 400
137
+ PostForMe::Errors::BadRequestError.new(**kwargs)
138
+ in 401
139
+ PostForMe::Errors::AuthenticationError.new(**kwargs)
140
+ in 403
141
+ PostForMe::Errors::PermissionDeniedError.new(**kwargs)
142
+ in 404
143
+ PostForMe::Errors::NotFoundError.new(**kwargs)
144
+ in 409
145
+ PostForMe::Errors::ConflictError.new(**kwargs)
146
+ in 422
147
+ PostForMe::Errors::UnprocessableEntityError.new(**kwargs)
148
+ in 429
149
+ PostForMe::Errors::RateLimitError.new(**kwargs)
150
+ in (500..)
151
+ PostForMe::Errors::InternalServerError.new(**kwargs)
152
+ else
153
+ PostForMe::Errors::APIStatusError.new(**kwargs)
154
+ end
155
+ end
156
+
157
+ # @!parse
158
+ # # @return [Integer]
159
+ # attr_accessor :status
160
+
161
+ # @api private
162
+ #
163
+ # @param url [URI::Generic]
164
+ # @param status [Integer]
165
+ # @param body [Object, nil]
166
+ # @param request [nil]
167
+ # @param response [nil]
168
+ # @param message [String, nil]
169
+ def initialize(url:, status:, body:, request:, response:, message: nil)
170
+ message ||= {url: url.to_s, status: status, body: body}
171
+ super(
172
+ url: url,
173
+ status: status,
174
+ body: body,
175
+ request: request,
176
+ response: response,
177
+ message: message&.to_s
178
+ )
179
+ end
180
+ end
181
+
182
+ class BadRequestError < PostForMe::Errors::APIStatusError
183
+ HTTP_STATUS = 400
184
+ end
185
+
186
+ class AuthenticationError < PostForMe::Errors::APIStatusError
187
+ HTTP_STATUS = 401
188
+ end
189
+
190
+ class PermissionDeniedError < PostForMe::Errors::APIStatusError
191
+ HTTP_STATUS = 403
192
+ end
193
+
194
+ class NotFoundError < PostForMe::Errors::APIStatusError
195
+ HTTP_STATUS = 404
196
+ end
197
+
198
+ class ConflictError < PostForMe::Errors::APIStatusError
199
+ HTTP_STATUS = 409
200
+ end
201
+
202
+ class UnprocessableEntityError < PostForMe::Errors::APIStatusError
203
+ HTTP_STATUS = 422
204
+ end
205
+
206
+ class RateLimitError < PostForMe::Errors::APIStatusError
207
+ HTTP_STATUS = 429
208
+ end
209
+
210
+ class InternalServerError < PostForMe::Errors::APIStatusError
211
+ HTTP_STATUS = (500..)
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PostForMe
4
+ class FilePart
5
+ # @return [Pathname, StringIO, IO, String]
6
+ attr_reader :content
7
+
8
+ # @return [String, nil]
9
+ attr_reader :content_type
10
+
11
+ # @return [String, nil]
12
+ attr_reader :filename
13
+
14
+ # @api private
15
+ #
16
+ # @return [String]
17
+ private def read
18
+ case content
19
+ in Pathname
20
+ content.read(binmode: true)
21
+ in StringIO
22
+ content.string
23
+ in IO
24
+ content.read
25
+ in String
26
+ content
27
+ end
28
+ end
29
+
30
+ # @param a [Object]
31
+ #
32
+ # @return [String]
33
+ def to_json(*a) = read.to_json(*a)
34
+
35
+ # @param a [Object]
36
+ #
37
+ # @return [String]
38
+ def to_yaml(*a) = read.to_yaml(*a)
39
+
40
+ # @param content [Pathname, StringIO, IO, String]
41
+ # @param filename [String, nil]
42
+ # @param content_type [String, nil]
43
+ def initialize(content, filename: nil, content_type: nil)
44
+ @content = content
45
+ @filename =
46
+ case content
47
+ in Pathname
48
+ filename.nil? ? content.basename.to_path : ::File.basename(filename)
49
+ else
50
+ filename.nil? ? nil : ::File.basename(filename)
51
+ end
52
+ @content_type = content_type
53
+ end
54
+ end
55
+ end