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 +4 -4
- data/README.md +158 -170
- data/lib/pushizo/base_resource.rb +14 -14
- data/lib/pushizo/client.rb +264 -264
- data/lib/pushizo/errors.rb +96 -96
- data/lib/pushizo/file_upload.rb +30 -30
- data/lib/pushizo/generated/models.rb +2681 -159
- data/lib/pushizo/generated/resources.rb +1629 -52
- data/lib/pushizo/identity_token.rb +40 -40
- data/lib/pushizo/model.rb +117 -117
- data/lib/pushizo/transport.rb +26 -26
- data/lib/pushizo/version.rb +5 -5
- data/lib/pushizo/webhook.rb +92 -92
- data/lib/pushizo.rb +27 -27
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11f24d14215cb41bcc613a5b28015ccbf779c58a1bb43a1334b317ecb75e31de
|
|
4
|
+
data.tar.gz: e913c8fcd9bc4bd4780e60e8dbf1d4c6c3724af57552756ac3acf60649565428
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|