Skip to content

Commit 58822ff

Browse files
authored
Merge pull request #6 from tapsilat/feat/models
feat/models
2 parents ae26f0a + 277682b commit 58822ff

22 files changed

Lines changed: 2761 additions & 1100 deletions

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_PATH: "vendor/bundle"

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ Thumbs.db
4949
# Temporary files
5050
*~
5151
*.swp
52-
*.swo
52+
*.swo
53+
# Test results and verification scripts
54+
exhaustive-verify.rb
55+
*-result.md
56+
*test-result*
57+
*.log
58+
.bundle
59+
.docker/

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in tapsilat.gemspec
44
gemspec
5+
6+
gem "base64", "~> 0.3.0"
7+
gem "mutex_m", "~> 0.3.0"
8+
gem "logger", "~> 1.7"

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ Or install it yourself as:
2020

2121
## Usage
2222

23-
Configure the client with your API credentials:
23+
Configure the client with your API credentials.
24+
25+
The client automatically reads `TAPSILAT_API_KEY` (or `TAPSILAT_API_TOKEN`) and `TAPSILAT_BASE_URL` from your environment variables.
26+
27+
Alternatively, you can configure it functionality:
2428

2529
```ruby
2630
Tapsilat.configure do |config|
27-
config.base_url = ENV['TAPSILAT_BASE_URL']
28-
config.api_token = ENV['TAPSILAT_API_TOKEN']
31+
config.base_url = 'https://panel.tapsilat.dev/api/v1'
32+
config.api_token = 'your-token'
2933
end
3034
```
3135

example.rb

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require_relative 'lib/tapsilat'
2+
require 'dotenv/load'
3+
4+
# Configure Tapsilat
5+
Tapsilat.configure do |config|
6+
config.base_url = ENV['TAPSILAT_BASE_URL'] || 'https://panel.tapsilat.dev/api/v1'
7+
config.api_token = ENV['TAPSILAT_API_KEY']
8+
end
9+
10+
client = Tapsilat::Client.new
11+
12+
puts "=== Tapsilat Ruby SDK Example (Modern Architecture) ==="
13+
14+
begin
15+
# 1. Organization Settings
16+
settings = client.organization.settings
17+
puts "✅ Organization Settings: #{settings['organization_name']}"
18+
19+
# 2. Build and Create Order
20+
buyer = Tapsilat::BuyerDTO.new(
21+
name: 'Ruby',
22+
surname: 'Tester',
23+
email: 'ruby.tester@example.com',
24+
gsm_number: '+905001234567',
25+
identity_number: '11111111111'
26+
)
27+
28+
order_req = client.orders.build_order(
29+
amount: 100.0,
30+
currency: 'TRY',
31+
locale: 'tr',
32+
buyer: buyer,
33+
conversation_id: "RUBY_EXAMPLE_#{Time.now.to_i}"
34+
)
35+
36+
# Add basket items
37+
order_req.basket_items = [
38+
Tapsilat::BasketItemDTO.new(id: 'P1', name: 'Premium Service', price: 100.0, quantity: 1, item_type: 'VIRTUAL')
39+
]
40+
41+
order_res = client.orders.create(order_req)
42+
puts "✅ Order Created: #{order_res.reference_id}"
43+
puts "🔗 Checkout URL: #{order_res.checkout_url}"
44+
45+
# 3. List Subscriptions
46+
subs = client.subscriptions.list(per_page: 5)
47+
puts "✅ Subscriptions listed. Count: #{subs['rows']&.size || 0}"
48+
49+
rescue => e
50+
puts "❌ Example failed: #{e.message}"
51+
puts e.backtrace.first(5)
52+
end

0 commit comments

Comments
 (0)