pushizo 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f33d90710be708d8c1564539e767f76f570f49505122780696d768ad402b66b
4
- data.tar.gz: 782a0f46dd24bb0248fa564180316575c2173f5b74115459a3ef494a5e249cd7
3
+ metadata.gz: 11f24d14215cb41bcc613a5b28015ccbf779c58a1bb43a1334b317ecb75e31de
4
+ data.tar.gz: e913c8fcd9bc4bd4780e60e8dbf1d4c6c3724af57552756ac3acf60649565428
5
5
  SHA512:
6
- metadata.gz: 1c674747a8637ae7cae4303f0b2125acda5317649b96004a890d02755160f77610852fd1ea481732e511746d5e60af579b30f0038d384d6e733f8f346cd3c066
7
- data.tar.gz: 2fc0239d42ebc22d32a228ac235ec33b3d145ee88615844c2b33ae2ad5635ef42f64136884e9fef849b076a787deb546cbe5d417bb0d10660a19d03df11dd19a
6
+ metadata.gz: bfa23d9c76e434add8fd6dc5966b0fa3b828f751e2bdbca0d4dffda1ec586a9a63e0107db819aabf0111f18d3aff098e430a3497bc87eea94bd6cb1130a77e63
7
+ data.tar.gz: d028eb7fc52aaad02dcdc2f75a5ffea84f2d2bac27de45ac7edb2e3da10f3822baed48debb7764f86755c4a713b5f65be209761307c1e0d2c3b6418858ff5cf9
data/README.md CHANGED
@@ -1,170 +1,158 @@
1
- <!-- pushizo:header -->
2
- <p align="center">
3
- <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
- </p>
5
- <p align="center">
6
- <a href="https://docs.pushizo.com/docs/sdk/ruby"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
- <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
- <a href="https://github.com/pushizo/pushizo-ruby/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
- </p>
10
- <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
11
-
12
- ## English
13
-
14
- **Pushizo Ruby SDK** — Server-side SDK for Ruby. Models and resources are generated from the Pushizo OpenAPI schema; retries, idempotency, pagination and webhook verification are built in. Works with Rails.
15
-
16
- > **Status:** Publishing to RubyGems is in progress.<br>
17
- > **Durum:** RubyGems yayını hazırlanıyor.
18
-
19
- **Install from GitHub until then · O zamana kadar GitHub'dan kurulum:**
20
-
21
- ```ruby
22
- # Gemfile
23
- gem "pushizo", git: "https://github.com/pushizo/pushizo-ruby", tag: "v0.1.0"
24
- ```
25
-
26
- **After publication · Yayından sonra:**
27
-
28
- ```bash
29
- gem install pushizo
30
- ```
31
-
32
- The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
33
- [docs.pushizo.com/docs/sdk/ruby](https://docs.pushizo.com/docs/sdk/ruby) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
34
-
35
- ## Türkçe
36
- <!-- /pushizo:header -->
37
-
38
- # Pushizo Ruby SDK
39
-
40
- Pushizo public API'si için Ruby sunucu SDK'sı (Ruby 3.0+, `Net::HTTP`; çalışma zamanı bağımlılığı yok).
41
- Modeller ve kaynak metotları [Pushizo OpenAPI şemasından](https://github.com/pushizo/pushizo-openapi) üretilir (`lib/pushizo/generated/`); kimlik doğrulama,
42
- yeniden deneme, idempotency, sayfalama ve webhook imza doğrulaması el yazımıdır.
43
-
44
- ## Kurulum
45
-
46
- ```ruby
47
- # Gemfile
48
- gem "pushizo"
49
- ```
50
-
51
- ## Kullanım
52
-
53
- ```ruby
54
- require "pushizo"
55
-
56
- hs = Pushizo::Client.new(api_key: ENV.fetch("HS_API_KEY"), app_id: "app_…") # yerelde base_url: "http://localhost:4000"
57
-
58
- # Bildirim gönder: Idempotency-Key verilmezse otomatik UUID (yeniden denemelerde aynı anahtar)
59
- res = hs.notifications.create(
60
- {
61
- target: { include_aliases: { external_id: ["user-42"] } },
62
- contents: { en: "Your order shipped", tr: "Siparişiniz kargoya verildi" }
63
- },
64
- idempotency_key: "order-1001"
65
- )
66
- puts res.id, res.status
67
-
68
- # Kullanıcı oluştur/güncelle (Hash veya model nesnesi kabul edilir)
69
- hs.users.upsert(Pushizo::Models::UpsertUserDto.new(external_id: "user-42", tags: { plan: "pro" }))
70
-
71
- # Cursor sayfalama: Enumerator, sayfalar tembel yüklenir
72
- hs.segments.list_all(limit: 100).each { |segment| puts segment.name }
73
-
74
- # Başka bir app için tek çağrı
75
- hs.apps.get(app_id: "app_diger")
76
-
77
- # SDK identity verification
78
- identity_hash = Pushizo.identity_hash(ENV.fetch("HS_SDK_SECRET"), "user-42")
79
- ```
80
-
81
- Yanıtlar `Pushizo::Models::*` nesneleridir: alanlara snake_case metotla (`msg.status`) veya `msg["status"]` ile
82
- erişilir, `to_h` JSON adlarıyla ham hash döner, bilinmeyen alanlar korunur. Ruby'nin `Object#send` yöntemiyle
83
- çakışmaması için `events.send` → `send_events`, `campaigns.send` → `send_campaign` olarak adlandırılmıştır.
84
- SDK'da metodu olmayan uçlar veya JSON dışı yanıtlar için
85
- `hs.request(:get, "/v1/apps/{appId}/analytics/messages", query: { format: "csv" })` kullanılabilir.
86
-
87
- ### Ayarlar
88
-
89
- | Parametre | Varsayılan | Açıklama |
90
- |-----------|------------|----------|
91
- | `api_key:` | — | `hs_live_…` API anahtarı (Bearer) |
92
- | `app_id:` | `nil` | Çağrıda `app_id:` verilmezse kullanılan app |
93
- | `base_url:` | `https://api.pushizo.com` | API adresi |
94
- | `timeout:` | `30` | Deneme başına zaman aşımı (sn) |
95
- | `max_retries:` | `3` | En fazla yeniden deneme (politika: aşağıda) |
96
- | `auto_idempotency_key:` | `true` | `Idempotency-Key` destekleyen çağrılarda otomatik UUID |
97
- | `transport:` | `NetHttpTransport` | Özel taşıma (`#call(method, url, headers, body, timeout)`) |
98
-
99
- Her çağrı `request_options: { timeout: 5, max_retries: 0, headers: { … } }` ile ayrıca ayarlanabilir.
100
-
101
- ### Hatalar
102
-
103
- 429 her metotta; 5xx ve ağ hataları GET/HEAD/OPTIONS/PUT/DELETE'te, POST/PATCH'te yalnızca `Idempotency-Key` varsa (otomatik anahtar dahil) veya istek sunucuya hiç gönderilemediyse (bağlantı reddi, DNS hatası, bağlantı zaman aşımı) üstel geri çekilmeyle (0,3 / 1 / 3 sn) yeniden denenir; `Retry-After` başlığına uyulur.
104
- Kalıcı hatalar `Pushizo::Error` alt sınıflarıdır ve `status`, `code` (`HS_…`), `request_id`, `details` taşır:
105
-
106
- ```ruby
107
- begin
108
- hs.notifications.get("msg_yok")
109
- rescue Pushizo::NotFoundError
110
- # 404
111
- rescue Pushizo::InvalidRequestError => e
112
- # 400/422 — e.code == Pushizo::ErrorCode::NO_RECIPIENTS
113
- rescue Pushizo::Error => e
114
- # AuthenticationError, PermissionDeniedError, ConflictError, RateLimitError, ServerError, NetworkError
115
- warn "#{e.status} #{e.code} #{e.message}"
116
- end
117
- ```
118
-
119
- ## Webhook imza doğrulaması
120
-
121
- ```ruby
122
- # Rails
123
- class PushizoWebhooksController < ActionController::API
124
- def create
125
- events = Pushizo::Webhook.construct_events(
126
- request.raw_post, # ham gövde
127
- request.headers["Pushizo-Signature"],
128
- ENV.fetch("HS_WEBHOOK_SECRET") # rotasyonda [eski, yeni] verilebilir
129
- )
130
- events.each { |event| } # tekil veya batch; event["id"] ile tekrarları ayıklayın
131
- head :no_content
132
- rescue Pushizo::WebhookSignatureError => e
133
- render plain: e.reason, status: :bad_request
134
- end
135
- end
136
- ```
137
-
138
- Zaman damgası 5 dakikadan eskiyse (`tolerance:`) istek tekrar (replay) sayılır. Yalnızca doğrulama için
139
- `Pushizo::Webhook.verify_signature(...)` `ok?`, `timestamp`, `reason` döner.
140
-
141
- ## Geliştirme
142
-
143
- ```bash
144
- rake test # veya: ruby -Ilib -Itest -e 'Dir["test/test_*.rb"].each { |f| require_relative f }'
145
- node sdk/scripts/generate-server-sdks.mjs --lang ruby # depo kökünde; generated/ yenilenir
146
- ```
147
-
148
- `lib/pushizo/generated/` elle düzenlenmez. Webhook testleri `sdk/testdata/webhook-signature-vectors.json`
149
- ortak vektörlerini kullanır.
150
-
151
- <!-- pushizo:footer -->
152
- ---
153
-
154
- ## Support · Destek
155
-
156
- - **Guide · Rehber:** [docs.pushizo.com/docs/sdk/ruby](https://docs.pushizo.com/docs/sdk/ruby)
157
- - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
158
- [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
159
- - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-ruby/issues)
160
- - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
161
- herkese açık issue açmayın, bu adrese yazın.
162
- - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
163
-
164
- This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
165
- instead of a pull request; fixes land in the main repository and ship with the next release.
166
- Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
167
- yapılır ve bir sonraki sürümle buraya gelir.
168
-
169
- Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-ruby/blob/main/LICENSE).
170
- <!-- /pushizo:footer -->
1
+ <!-- pushizo:header -->
2
+ <p align="center">
3
+ <a href="https://pushizo.com"><img src="https://raw.githubusercontent.com/pushizo/.github/main/profile/assets/mark.svg" alt="Pushizo" width="56" height="56"></a>
4
+ </p>
5
+ <p align="center">
6
+ <a href="https://docs.pushizo.com/docs/sdk/ruby"><img src="https://img.shields.io/badge/docs-docs.pushizo.com-5b4bdb" alt="Docs"></a>
7
+ <a href="https://docs.pushizo.com/docs/api"><img src="https://img.shields.io/badge/API-reference-b44fc4" alt="API reference"></a>
8
+ <a href="https://github.com/pushizo/pushizo-ruby/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-16130f" alt="License: MIT"></a>
9
+ </p>
10
+ <p align="center"><a href="#english">English</a> · <a href="#türkçe">Türkçe</a></p>
11
+
12
+ ## English
13
+
14
+ **Pushizo Ruby SDK** — Server-side SDK for Ruby. Models and resources are generated from the Pushizo OpenAPI schema; retries, idempotency, pagination and webhook verification are built in. Works with Rails.
15
+
16
+ ```bash
17
+ gem install pushizo
18
+ ```
19
+
20
+ The detailed guide below is in Turkish; code samples are language-neutral. Full documentation:
21
+ [docs.pushizo.com/docs/sdk/ruby](https://docs.pushizo.com/docs/sdk/ruby) · API reference: [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api).
22
+
23
+ ## Türkçe
24
+ <!-- /pushizo:header -->
25
+
26
+ # Pushizo Ruby SDK
27
+
28
+ Pushizo public API'si için Ruby sunucu SDK'sı (Ruby 3.0+, `Net::HTTP`; çalışma zamanı bağımlılığı yok).
29
+ Modeller ve kaynak metotları [Pushizo OpenAPI şemasından](https://github.com/pushizo/pushizo-openapi) üretilir (`lib/pushizo/generated/`); kimlik doğrulama,
30
+ yeniden deneme, idempotency, sayfalama ve webhook imza doğrulaması el yazımıdır.
31
+
32
+ ## Kurulum
33
+
34
+ ```ruby
35
+ # Gemfile
36
+ gem "pushizo"
37
+ ```
38
+
39
+ ## Kullanım
40
+
41
+ ```ruby
42
+ require "pushizo"
43
+
44
+ hs = Pushizo::Client.new(api_key: ENV.fetch("HS_API_KEY"), app_id: "app_…") # yerelde base_url: "http://localhost:4000"
45
+
46
+ # Bildirim gönder: Idempotency-Key verilmezse otomatik UUID (yeniden denemelerde aynı anahtar)
47
+ res = hs.notifications.create(
48
+ {
49
+ target: { include_aliases: { external_id: ["user-42"] } },
50
+ contents: { en: "Your order shipped", tr: "Siparişiniz kargoya verildi" }
51
+ },
52
+ idempotency_key: "order-1001"
53
+ )
54
+ puts res.id, res.status
55
+
56
+ # Kullanıcı oluştur/güncelle (Hash veya model nesnesi kabul edilir)
57
+ hs.users.upsert(Pushizo::Models::UpsertUserDto.new(external_id: "user-42", tags: { plan: "pro" }))
58
+
59
+ # Cursor sayfalama: Enumerator, sayfalar tembel yüklenir
60
+ hs.segments.list_all(limit: 100).each { |segment| puts segment.name }
61
+
62
+ # Başka bir app için tek çağrı
63
+ hs.apps.get(app_id: "app_diger")
64
+
65
+ # SDK identity verification
66
+ identity_hash = Pushizo.identity_hash(ENV.fetch("HS_SDK_SECRET"), "user-42")
67
+ ```
68
+
69
+ Yanıtlar `Pushizo::Models::*` nesneleridir: alanlara snake_case metotla (`msg.status`) veya `msg["status"]` ile
70
+ erişilir, `to_h` JSON adlarıyla ham hash döner, bilinmeyen alanlar korunur. Ruby'nin `Object#send` yöntemiyle
71
+ çakışmaması için `events.send` → `send_events`, `campaigns.send` → `send_campaign` olarak adlandırılmıştır.
72
+ SDK'da metodu olmayan uçlar veya JSON dışı yanıtlar için
73
+ `hs.request(:get, "/v1/apps/{appId}/analytics/messages", query: { format: "csv" })` kullanılabilir.
74
+
75
+ ### Ayarlar
76
+
77
+ | Parametre | Varsayılan | Açıklama |
78
+ |-----------|------------|----------|
79
+ | `api_key:` | — | `hs_live_…` API anahtarı (Bearer) |
80
+ | `app_id:` | `nil` | Çağrıda `app_id:` verilmezse kullanılan app |
81
+ | `base_url:` | `https://api.pushizo.com` | API adresi |
82
+ | `timeout:` | `30` | Deneme başına zaman aşımı (sn) |
83
+ | `max_retries:` | `3` | En fazla yeniden deneme (politika: aşağıda) |
84
+ | `auto_idempotency_key:` | `true` | `Idempotency-Key` destekleyen çağrılarda otomatik UUID |
85
+ | `transport:` | `NetHttpTransport` | Özel taşıma (`#call(method, url, headers, body, timeout)`) |
86
+
87
+ Her çağrı `request_options: { timeout: 5, max_retries: 0, headers: { … } }` ile ayrıca ayarlanabilir.
88
+
89
+ ### Hatalar
90
+
91
+ 429 her metotta; 5xx ve ağ hataları GET/HEAD/OPTIONS/PUT/DELETE'te, POST/PATCH'te yalnızca `Idempotency-Key` varsa (otomatik anahtar dahil) veya istek sunucuya hiç gönderilemediyse (bağlantı reddi, DNS hatası, bağlantı zaman aşımı) üstel geri çekilmeyle (0,3 / 1 / 3 sn) yeniden denenir; `Retry-After` başlığına uyulur.
92
+ Kalıcı hatalar `Pushizo::Error` alt sınıflarıdır ve `status`, `code` (`HS_…`), `request_id`, `details` taşır:
93
+
94
+ ```ruby
95
+ begin
96
+ hs.notifications.get("msg_yok")
97
+ rescue Pushizo::NotFoundError
98
+ # 404
99
+ rescue Pushizo::InvalidRequestError => e
100
+ # 400/422 — e.code == Pushizo::ErrorCode::NO_RECIPIENTS
101
+ rescue Pushizo::Error => e
102
+ # AuthenticationError, PermissionDeniedError, ConflictError, RateLimitError, ServerError, NetworkError
103
+ warn "#{e.status} #{e.code} #{e.message}"
104
+ end
105
+ ```
106
+
107
+ ## Webhook imza doğrulaması
108
+
109
+ ```ruby
110
+ # Rails
111
+ class PushizoWebhooksController < ActionController::API
112
+ def create
113
+ events = Pushizo::Webhook.construct_events(
114
+ request.raw_post, # ham gövde
115
+ request.headers["Pushizo-Signature"],
116
+ ENV.fetch("HS_WEBHOOK_SECRET") # rotasyonda [eski, yeni] verilebilir
117
+ )
118
+ events.each { |event| } # tekil veya batch; event["id"] ile tekrarları ayıklayın
119
+ head :no_content
120
+ rescue Pushizo::WebhookSignatureError => e
121
+ render plain: e.reason, status: :bad_request
122
+ end
123
+ end
124
+ ```
125
+
126
+ Zaman damgası 5 dakikadan eskiyse (`tolerance:`) istek tekrar (replay) sayılır. Yalnızca doğrulama için
127
+ `Pushizo::Webhook.verify_signature(...)` `ok?`, `timestamp`, `reason` döner.
128
+
129
+ ## Geliştirme
130
+
131
+ ```bash
132
+ rake test # veya: ruby -Ilib -Itest -e 'Dir["test/test_*.rb"].each { |f| require_relative f }'
133
+ node sdk/scripts/generate-server-sdks.mjs --lang ruby # depo kökünde; generated/ yenilenir
134
+ ```
135
+
136
+ `lib/pushizo/generated/` elle düzenlenmez. Webhook testleri `sdk/testdata/webhook-signature-vectors.json`
137
+ ortak vektörlerini kullanır.
138
+
139
+ <!-- pushizo:footer -->
140
+ ---
141
+
142
+ ## Support · Destek
143
+
144
+ - **Guide · Rehber:** [docs.pushizo.com/docs/sdk/ruby](https://docs.pushizo.com/docs/sdk/ruby)
145
+ - **API reference & OpenAPI · API referansı ve OpenAPI:** [docs.pushizo.com/docs/api](https://docs.pushizo.com/docs/api) ·
146
+ [pushizo-openapi](https://github.com/pushizo/pushizo-openapi)
147
+ - **Bugs & ideas · Hata ve öneri:** [Issues](https://github.com/pushizo/pushizo-ruby/issues)
148
+ - **Security · Güvenlik:** please do not open public issues; email [security@pushizo.com](mailto:security@pushizo.com) ·
149
+ herkese açık issue açmayın, bu adrese yazın.
150
+ - **Help · Destek:** [support@pushizo.com](mailto:support@pushizo.com)
151
+
152
+ This repository is mirrored automatically from the Pushizo main repository on every release. Please open an issue
153
+ instead of a pull request; fixes land in the main repository and ship with the next release.
154
+ Bu depo her sürümde Pushizo ana deposundan otomatik yansıtılır. Pull request yerine issue açın; düzeltmeler ana depoda
155
+ yapılır ve bir sonraki sürümle buraya gelir.
156
+
157
+ Released under the MIT License · MIT lisanslıdır — [LICENSE](https://github.com/pushizo/pushizo-ruby/blob/main/LICENSE).
158
+ <!-- /pushizo:footer -->
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- module Pushizo
4
- # Üretilmiş kaynak sınıflarının tabanı.
5
- class BaseResource
6
- def initialize(client)
7
- @client = client
8
- end
9
-
10
- def inspect
11
- "#<#{self.class.name}>"
12
- end
13
- end
14
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Pushizo
4
+ # Üretilmiş kaynak sınıflarının tabanı.
5
+ class BaseResource
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ def inspect
11
+ "#<#{self.class.name}>"
12
+ end
13
+ end
14
+ end