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(
139139 year: year
140140)
141141
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+
142146# # You can also specify a project-id field (optional) to be used instead of the preferred one
143147project_id = ' pro_test_1234' # Pass in the project's ID
144148Patch ::Estimate .create_mass_estimate(mass_g: mass, project_id: project_id)
@@ -218,30 +222,30 @@ Patch::Preference.retrieve_preferences(page: page)
218222
219223To build the gem locally, run:
220224
221- ```
222- $ gem build patch_ruby.gemspec
225+ ``` bash
226+ gem build patch_ruby.gemspec
223227```
224228
225229This will create a .gem file. To install the local gem:
226230
227- ```
228- $ gem install patch_ruby-1.x.x.gem
231+ ``` bash
232+ gem install patch_ruby-1.x.x.gem
229233```
230234
231235Install dependencies:
232236
233- ```
234- $ bundle install
237+ ``` bash
238+ bundle install
235239```
236240
237241Set up required environment variables:
238242
239- ```
240- $ export SANDBOX_API_KEY=<SANDBOX API KEY>
243+ ``` bash
244+ export SANDBOX_API_KEY=< SANDBOX API KEY>
241245```
242246
243247Run tests:
244248
245- ```
246- $ bundle exec rspec
249+ ``` bash
250+ bundle exec rspec
247251```
Original file line number Diff line number Diff line change 7979 expect ( create_estimate_response . data . type ) . to eq 'shipping'
8080 expect ( create_estimate_response . data . mass_g ) . to eq 12_431
8181 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
82102end
Original file line number Diff line number Diff line change 4444 expect ( create_order_response . success ) . to eq true
4545 expect ( order . id ) . not_to be_nil
4646 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 )
4848 expect ( order . patch_fee_cents_usd ) . not_to be_empty
49+ expect ( order . registry_url ) . not_to be_empty
4950 end
5051
5152 it 'supports create with a total price' do
6667 order = create_order_response . data
6768
6869 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
7072 expect ( order . price_cents_usd ) . not_to be_empty
7173 expect ( order . patch_fee_cents_usd ) . not_to be_empty
7274 expect (
7375 order . price_cents_usd . to_i + order . patch_fee_cents_usd . to_i
7476 ) . to eq ( total_price_cents_usd )
77+ expect ( order . registry_url ) . not_to be_empty
7578 end
7679
7780 it 'supports create with metadata' do
You can’t perform that action at this time.
0 commit comments