File tree Expand file tree Collapse file tree 3 files changed +39
-12
lines changed Expand file tree Collapse file tree 3 files changed +39
-12
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,10 @@ Patch::Estimate.create_vehicle_estimate(
139
139
year: year
140
140
)
141
141
142
+ # Create a flight estimate
143
+ transaction_value_btc_sats = 1000 ; # [Optional] Pass in the transaction value in satoshis
144
+ Patch ::Estimate .create_bitcoin_estimate(transaction_value_btc_sats: transaction_value_btc_sats)
145
+
142
146
# # You can also specify a project-id field (optional) to be used instead of the preferred one
143
147
project_id = ' pro_test_1234' # Pass in the project's ID
144
148
Patch ::Estimate .create_mass_estimate(mass_g: mass, project_id: project_id)
@@ -218,30 +222,30 @@ Patch::Preference.retrieve_preferences(page: page)
218
222
219
223
To build the gem locally, run:
220
224
221
- ```
222
- $ gem build patch_ruby.gemspec
225
+ ``` bash
226
+ gem build patch_ruby.gemspec
223
227
```
224
228
225
229
This will create a .gem file. To install the local gem:
226
230
227
- ```
228
- $ gem install patch_ruby-1.x.x.gem
231
+ ``` bash
232
+ gem install patch_ruby-1.x.x.gem
229
233
```
230
234
231
235
Install dependencies:
232
236
233
- ```
234
- $ bundle install
237
+ ``` bash
238
+ bundle install
235
239
```
236
240
237
241
Set up required environment variables:
238
242
239
- ```
240
- $ export SANDBOX_API_KEY=<SANDBOX API KEY>
243
+ ``` bash
244
+ export SANDBOX_API_KEY=< SANDBOX API KEY>
241
245
```
242
246
243
247
Run tests:
244
248
245
- ```
246
- $ bundle exec rspec
249
+ ``` bash
250
+ bundle exec rspec
247
251
```
Original file line number Diff line number Diff line change 79
79
expect ( create_estimate_response . data . type ) . to eq 'shipping'
80
80
expect ( create_estimate_response . data . mass_g ) . to eq 12_431
81
81
end
82
+
83
+ it 'supports creating bitcoin estimates with partial information' do
84
+ bitcoin_estimate = Patch ::Estimate . create_bitcoin_estimate ( { create_order : false } )
85
+
86
+ expect ( bitcoin_estimate . data . type ) . to eq 'bitcoin'
87
+ expect ( bitcoin_estimate . data . mass_g ) . to be >= 2_000
88
+ end
89
+
90
+ it 'supports creating bitcoin estimates with a transaction amount' do
91
+ bitcoin_estimate = Patch ::Estimate . create_bitcoin_estimate (
92
+ transaction_value_btc_sats : 10_000
93
+ )
94
+
95
+ bitcoin_estimate_2 = Patch ::Estimate . create_bitcoin_estimate (
96
+ transaction_value_btc_sats : 100_000
97
+ )
98
+
99
+ expect ( bitcoin_estimate . data . type ) . to eq 'bitcoin'
100
+ expect ( bitcoin_estimate . data . mass_g ) . to be < bitcoin_estimate_2 . data . mass_g
101
+ end
82
102
end
Original file line number Diff line number Diff line change 44
44
expect ( create_order_response . success ) . to eq true
45
45
expect ( order . id ) . not_to be_nil
46
46
expect ( order . mass_g ) . to eq ( order_mass_g )
47
- expect ( order . price_cents_usd . to_i ) . to be_between ( expected_price - 1 , expected_price + 1 )
47
+ expect ( order . price_cents_usd . to_i ) . to be_between ( expected_price - 2 , expected_price + 2 )
48
48
expect ( order . patch_fee_cents_usd ) . not_to be_empty
49
+ expect ( order . registry_url ) . not_to be_empty
49
50
end
50
51
51
52
it 'supports create with a total price' do
66
67
order = create_order_response . data
67
68
68
69
expect ( order . id ) . not_to be_nil
69
- expect ( order . mass_g ) . to eq ( 5_00_000 )
70
+ expect ( order . mass_g ) . to be > 450_000
71
+ expect ( order . mass_g ) . to be < 460_000
70
72
expect ( order . price_cents_usd ) . not_to be_empty
71
73
expect ( order . patch_fee_cents_usd ) . not_to be_empty
72
74
expect (
73
75
order . price_cents_usd . to_i + order . patch_fee_cents_usd . to_i
74
76
) . to eq ( total_price_cents_usd )
77
+ expect ( order . registry_url ) . not_to be_empty
75
78
end
76
79
77
80
it 'supports create with metadata' do
You can’t perform that action at this time.
0 commit comments