|
24 | 24 | easypost_details: easypost_details, |
25 | 25 | } |
26 | 26 |
|
| 27 | + json_response = { |
| 28 | + 'email_address' => nil, |
| 29 | + 'options' => %w[SMS CALL INVOICE], |
| 30 | + 'phone_number' => '***-***-9721', |
| 31 | + } |
| 32 | + |
| 33 | + allow(client).to receive(:make_request).with( |
| 34 | + :post, |
| 35 | + "fedex_registrations/#{fedex_account_number}/address", |
| 36 | + params, |
| 37 | + ).and_return(json_response) |
| 38 | + |
27 | 39 | response = client.fedex_registration.register_address(fedex_account_number, params) |
28 | 40 |
|
29 | | - expect(response).to be_an_instance_of(EasyPost::Models::FedExAccountValidationResponse) |
| 41 | + expect(response).to be_an_instance_of(EasyPost::Models::EasyPostObject) |
30 | 42 | expect(response.email_address).to be_nil |
31 | 43 | expect(response.options).to include('SMS') |
32 | 44 | expect(response.options).to include('CALL') |
|
38 | 50 | describe '.request_pin' do |
39 | 51 | it 'requests a pin' do |
40 | 52 | fedex_account_number = '123456789' |
| 53 | + wrapped_params = { |
| 54 | + pin_method: { |
| 55 | + option: 'SMS', |
| 56 | + }, |
| 57 | + } |
| 58 | + |
| 59 | + json_response = { |
| 60 | + 'message' => 'sent secured Pin', |
| 61 | + } |
| 62 | + |
| 63 | + allow(client).to receive(:make_request).with( |
| 64 | + :post, |
| 65 | + "fedex_registrations/#{fedex_account_number}/pin", |
| 66 | + wrapped_params, |
| 67 | + ).and_return(json_response) |
41 | 68 |
|
42 | 69 | response = client.fedex_registration.request_pin(fedex_account_number, 'SMS') |
43 | 70 |
|
44 | | - expect(response).to be_an_instance_of(EasyPost::Models::FedExRequestPinResponse) |
| 71 | + expect(response).to be_an_instance_of(EasyPost::Models::EasyPostObject) |
45 | 72 | expect(response.message).to eq('sent secured Pin') |
46 | 73 | end |
47 | 74 | end |
|
61 | 88 | easypost_details: easypost_details, |
62 | 89 | } |
63 | 90 |
|
| 91 | + json_response = { |
| 92 | + 'id' => 'ca_123', |
| 93 | + 'object' => 'CarrierAccount', |
| 94 | + 'type' => 'FedexAccount', |
| 95 | + 'credentials' => { |
| 96 | + 'account_number' => '123456789', |
| 97 | + 'mfa_key' => '123456789-XXXXX', |
| 98 | + }, |
| 99 | + } |
| 100 | + |
| 101 | + allow(client).to receive(:make_request).with( |
| 102 | + :post, |
| 103 | + "fedex_registrations/#{fedex_account_number}/pin/validate", |
| 104 | + params, |
| 105 | + ).and_return(json_response) |
| 106 | + |
64 | 107 | response = client.fedex_registration.validate_pin(fedex_account_number, params) |
65 | 108 |
|
66 | | - expect(response).to be_an_instance_of(EasyPost::Models::FedExAccountValidationResponse) |
| 109 | + expect(response).to be_an_instance_of(EasyPost::Models::EasyPostObject) |
67 | 110 | expect(response.id).to eq('ca_123') |
68 | 111 | expect(response.object).to eq('CarrierAccount') |
69 | 112 | expect(response.type).to eq('FedexAccount') |
|
90 | 133 | easypost_details: easypost_details, |
91 | 134 | } |
92 | 135 |
|
| 136 | + json_response = { |
| 137 | + 'id' => 'ca_123', |
| 138 | + 'object' => 'CarrierAccount', |
| 139 | + 'type' => 'FedexAccount', |
| 140 | + 'credentials' => { |
| 141 | + 'account_number' => '123456789', |
| 142 | + 'mfa_key' => '123456789-XXXXX', |
| 143 | + }, |
| 144 | + } |
| 145 | + |
| 146 | + allow(client).to receive(:make_request).with( |
| 147 | + :post, |
| 148 | + "fedex_registrations/#{fedex_account_number}/invoice", |
| 149 | + params, |
| 150 | + ).and_return(json_response) |
| 151 | + |
93 | 152 | response = client.fedex_registration.submit_invoice(fedex_account_number, params) |
94 | 153 |
|
95 | | - expect(response).to be_an_instance_of(EasyPost::Models::FedExAccountValidationResponse) |
| 154 | + expect(response).to be_an_instance_of(EasyPost::Models::EasyPostObject) |
96 | 155 | expect(response.id).to eq('ca_123') |
97 | 156 | expect(response.object).to eq('CarrierAccount') |
98 | 157 | expect(response.type).to eq('FedexAccount') |
|
0 commit comments