You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This resource allows you to send HTTP requests to StarkBank routes.
2470
+
2471
+
## GET
2472
+
2473
+
You can perform a GET request to any StarkBank route.
2474
+
2475
+
It's possible to get a single resource using its id in the path.
2476
+
2477
+
```ruby
2478
+
require('starkbank')
2479
+
2480
+
example_id ="5155165527080960"
2481
+
request =StarkBank::Request.get(
2482
+
path:"/invoice/#{example_id}"
2483
+
).json
2484
+
2485
+
puts request
2486
+
```
2487
+
2488
+
You can also get the specific resource log,
2489
+
2490
+
```ruby
2491
+
require('starkbank')
2492
+
2493
+
example_id ="5699165527090460"
2494
+
request =StarkBank::Request.get(
2495
+
path:"/invoice/log/#{example_id}",
2496
+
).json
2497
+
2498
+
puts request
2499
+
```
2500
+
2501
+
This same method will be used to list all created items for the requested resource.
2502
+
2503
+
```ruby
2504
+
require('starkbank')
2505
+
2506
+
request =StarkBank::Request.get(
2507
+
path:"/invoice",
2508
+
query:{"limit": 10, "status": "paid"},
2509
+
).json
2510
+
2511
+
puts request
2512
+
```
2513
+
2514
+
To list logs, you will use the same logic as for getting a single log.
2515
+
2516
+
```ruby
2517
+
require('starkbank')
2518
+
2519
+
request =StarkBank::Request.get(
2520
+
path:"/invoice/log",
2521
+
query:{"limit": 10, "status": "paid"},
2522
+
).json
2523
+
2524
+
puts request
2525
+
```
2526
+
2527
+
You can get a resource file using this method.
2528
+
2529
+
```ruby
2530
+
require('starkbank')
2531
+
2532
+
example_id ="5155165527080960"
2533
+
pdf =StarkBank::Request.get(
2534
+
path:"/invoice/#{example_id}/pdf",
2535
+
).content
2536
+
File.binwrite('invoice.pdf', pdf)
2537
+
```
2538
+
2539
+
## POST
2540
+
2541
+
You can perform a POST request to any StarkBank route.
2542
+
2543
+
This will create an object for each item sent in your request
2544
+
2545
+
**Note**: It's not possible to create multiple resources simultaneously. You need to send separate requests if you want to create multiple resources, such as invoices and boletos.
2546
+
2547
+
```ruby
2548
+
require('starkbank')
2549
+
2550
+
data={
2551
+
"invoices": [
2552
+
{
2553
+
"amount": 100,
2554
+
"name": "Iron Bank S.A.",
2555
+
"taxId": "20.018.183/0001-80"
2556
+
},
2557
+
{
2558
+
"amount": 450000,
2559
+
"name": "Arya Stark.",
2560
+
"taxId": "012.345.678-90"
2561
+
}
2562
+
]
2563
+
}
2564
+
request =StarkBank::Request.get(
2565
+
path:"/invoice",
2566
+
body:data
2567
+
).json
2568
+
puts request
2569
+
```
2570
+
2571
+
## PATCH
2572
+
2573
+
You can perform a PATCH request to any StarkBank route.
2574
+
2575
+
It's possible to update a single item of a StarkBank resource.
2576
+
```ruby
2577
+
require('starkbank')
2578
+
2579
+
example_id ="5155165527080960"
2580
+
request =StarkBank::Request.patch(
2581
+
path:"/invoice/#{example_id}",
2582
+
body:{"amount": 0},
2583
+
).json
2584
+
puts request
2585
+
```
2586
+
2587
+
## PUT
2588
+
2589
+
You can perform a PUT request to any StarkBank route.
2590
+
2591
+
It's possible to put a single item of a StarkBank resource.
2592
+
```ruby
2593
+
require('starkbank')
2594
+
2595
+
data = {
2596
+
"profiles": [
2597
+
{
2598
+
"interval": "day",
2599
+
"delay": 0
2600
+
}
2601
+
]
2602
+
}
2603
+
request =StarkBank::Request.put(
2604
+
path:"/split-profile",
2605
+
body:data,
2606
+
).json
2607
+
puts request
2608
+
```
2609
+
## DELETE
2610
+
2611
+
You can perform a DELETE request to any StarkBank route.
2612
+
2613
+
It's possible to delete items of StarkBank resource.
2614
+
```ruby
2615
+
require('starkbank')
2616
+
2617
+
example_id ="5155165527080960"
2618
+
request =StarkBank::Request.delete(
2619
+
path:"/transfer/#{example_id}",
2620
+
).json
2621
+
puts request
2622
+
```
2623
+
2466
2624
# Handling errors
2467
2625
2468
2626
The SDK may raise one of four types of errors: __InputErrors__, __InternalServerError__, __UnknownError__, __InvalidSignatureError__
0 commit comments