usps-imis-api 0.9.8 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +20 -2
  4. data/Readme.md +2 -0
  5. data/lib/usps/imis/api.rb +11 -12
  6. data/lib/usps/imis/business_object.rb +7 -8
  7. data/lib/usps/imis/data.rb +4 -0
  8. data/lib/usps/imis/error.rb +1 -1
  9. data/lib/usps/imis/query.rb +50 -18
  10. data/lib/usps/imis/requests.rb +7 -3
  11. data/lib/usps/imis/version.rb +1 -1
  12. data/spec/fixtures/vcr_cassettes/.keep +0 -0
  13. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_authorize/automatically_refreshes_an_expired_token.yml +67 -0
  14. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/gets_the_iMIS_ID.yml +131 -0
  15. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/with_a_query_error/wraps_errors.yml +67 -0
  16. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/does_not_show_the_token_instance_variable.yml +67 -0
  17. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/is_configured_to_exclude_the_token_instance_variable.yml +67 -0
  18. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/chains_with_on_to_a_single_block.yml +256 -0
  19. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/nests_on_and_with.yml +256 -0
  20. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/returns_a_BusinessObject_without_a_block.yml +67 -0
  21. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/sends_an_update_from_put.yml +256 -0
  22. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/sends_an_update.yml +256 -0
  23. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/when_receiving_a_response_error/wraps_the_error.yml +67 -0
  24. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_query/collects_all_query_results.yml +67 -0
  25. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_.yml +67 -0
  26. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_for.yml +67 -0
  27. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_put.yml +256 -0
  28. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_update.yml +256 -0
  29. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/uses_a_panel_correctly.yml +145 -0
  30. data/spec/fixtures/vcr_cassettes/Usps_Imis_Api/stores_the_initial_imis_id.yml +67 -0
  31. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/_put_field/submits_the_correct_update_request.yml +627 -0
  32. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_filter_fields/formats_fields_correctly.yml +67 -0
  33. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/delegation_to_get_fields/delegates_to_get_fields.yml +67 -0
  34. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/returns_multiple_values.yml +67 -0
  35. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_a_string_value.yml +67 -0
  36. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_an_integer_value.yml +67 -0
  37. data/spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_fields/returns_multiple_values.yml +67 -0
  38. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/fetches_a_mapped_field.yml +158 -0
  39. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/raises_for_unmapped_updates.yml +67 -0
  40. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax.yml +158 -0
  41. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax_on_the_Api_directly.yml +158 -0
  42. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/raises_for_unmapped_updates.yml +67 -0
  43. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/sends_a_mapped_update.yml +256 -0
  44. data/spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/initialize_with_imis_id/stores_the_initial_imis_id.yml +67 -0
  45. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_business_object_to_be_defined.yml +67 -0
  46. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_payload_data_to_be_defined.yml +67 -0
  47. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/loads_a_specific_object.yml +146 -0
  48. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/returns_specific_fields.yml +146 -0
  49. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_field/returns_a_specific_field.yml +146 -0
  50. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_fields/returns_specific_fields.yml +146 -0
  51. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/interacts_with_records_correctly.yml +495 -0
  52. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/initialization_with_ID/can_initialize_with_an_iMIS_ID.yml +67 -0
  53. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/_get/loads_a_specific_object.yml +145 -0
  54. data/spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/handles_new_records_correctly.yml +319 -0
  55. data/spec/lib/usps/imis/api_spec.rb +4 -14
  56. data/spec/lib/usps/imis/business_object_spec.rb +1 -1
  57. data/spec/lib/usps/imis/data_spec.rb +9 -0
  58. data/spec/lib/usps/imis/mapper_spec.rb +1 -1
  59. data/spec/lib/usps/imis/panels/base_panel_spec.rb +1 -1
  60. data/spec/lib/usps/imis/panels/education_spec.rb +1 -1
  61. data/spec/lib/usps/imis/panels/vsc_spec.rb +1 -1
  62. data/spec/spec_helper.rb +40 -0
  63. metadata +44 -1
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,46 @@ require 'active_support/string_inquirer'
11
11
 
12
12
  ENV['TESTING'] = 'true'
13
13
 
14
+ require 'vcr'
15
+ require 'webmock/rspec'
16
+ WebMock.disable_net_connect!
17
+ record_mode = ENV['VCR'] ? ENV['VCR'].to_sym : :once
18
+ VCR.configure do |config|
19
+ config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
20
+ config.hook_into :webmock
21
+ config.default_cassette_options = {
22
+ record: record_mode,
23
+ match_requests_on: %i[method uri]
24
+ }
25
+ config.configure_rspec_metadata!
26
+
27
+ config.filter_sensitive_data('<USERNAME>') { ENV.fetch('IMIS_USERNAME') }
28
+ config.filter_sensitive_data('<USERNAME>') { CGI.escape(ENV.fetch('IMIS_USERNAME')) }
29
+
30
+ config.filter_sensitive_data('<PASSWORD>') { ENV.fetch('IMIS_PASSWORD') }
31
+ config.filter_sensitive_data('<PASSWORD>') { CGI.escape(ENV.fetch('IMIS_PASSWORD')) }
32
+
33
+ config.filter_sensitive_data('<ACCESS_TOKEN>') do |interaction|
34
+ if interaction.response.headers['Content-Type']&.first&.include?('application/json')
35
+ begin
36
+ response_body = JSON.parse(interaction.response.body)
37
+ response_body['access_token']
38
+ rescue JSON::ParserError
39
+ nil
40
+ end
41
+ end
42
+ end
43
+
44
+ config.filter_sensitive_data('<BEARER_TOKEN>') do |interaction|
45
+ if interaction.request.headers['Authorization']
46
+ auth_header = interaction.request.headers['Authorization'].first
47
+ if (match = auth_header.match(/^Bearer\s+([^,\s]+)/))
48
+ match.captures.first
49
+ end
50
+ end
51
+ end
52
+ end
53
+
14
54
  RSpec.configure do |config|
15
55
  # Enable flags like --only-failures and --next-failure
16
56
  config.example_status_persistence_file_path = 'tmp/.rspec_status'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -66,6 +66,49 @@ files:
66
66
  - lib/usps/imis/query.rb
67
67
  - lib/usps/imis/requests.rb
68
68
  - lib/usps/imis/version.rb
69
+ - spec/fixtures/vcr_cassettes/.keep
70
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_authorize/automatically_refreshes_an_expired_token.yml
71
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/gets_the_iMIS_ID.yml
72
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_imis_id_for/with_a_query_error/wraps_errors.yml
73
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/does_not_show_the_token_instance_variable.yml
74
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_inspect/is_configured_to_exclude_the_token_instance_variable.yml
75
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/chains_with_on_to_a_single_block.yml
76
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/nests_on_and_with.yml
77
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/returns_a_BusinessObject_without_a_block.yml
78
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_on/sends_an_update_from_put.yml
79
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/sends_an_update.yml
80
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_put/when_receiving_a_response_error/wraps_the_error.yml
81
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_query/collects_all_query_results.yml
82
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_.yml
83
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/blocks_calling_imis_id_for.yml
84
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_put.yml
85
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/sends_an_update_from_update.yml
86
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/_with/uses_a_panel_correctly.yml
87
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Api/stores_the_initial_imis_id.yml
88
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/_put_field/submits_the_correct_update_request.yml
89
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_filter_fields/formats_fields_correctly.yml
90
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/delegation_to_get_fields/delegates_to_get_fields.yml
91
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get/returns_multiple_values.yml
92
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_a_string_value.yml
93
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_field/returns_an_integer_value.yml
94
+ - spec/fixtures/vcr_cassettes/Usps_Imis_BusinessObject/with_stubbed_data/_get_fields/returns_multiple_values.yml
95
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/fetches_a_mapped_field.yml
96
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/raises_for_unmapped_updates.yml
97
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax.yml
98
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_fetch/supports_Hash_access_syntax_on_the_Api_directly.yml
99
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/raises_for_unmapped_updates.yml
100
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/_update/sends_a_mapped_update.yml
101
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Mapper/initialize_with_imis_id/stores_the_initial_imis_id.yml
102
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_business_object_to_be_defined.yml
103
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_BasePanel/requires_payload_data_to_be_defined.yml
104
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/loads_a_specific_object.yml
105
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get/returns_specific_fields.yml
106
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_field/returns_a_specific_field.yml
107
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/_get_fields/returns_specific_fields.yml
108
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/api_example/interacts_with_records_correctly.yml
109
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Education/initialization_with_ID/can_initialize_with_an_iMIS_ID.yml
110
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/_get/loads_a_specific_object.yml
111
+ - spec/fixtures/vcr_cassettes/Usps_Imis_Panels_Vsc/handles_new_records_correctly.yml
69
112
  - spec/lib/usps/imis/api_spec.rb
70
113
  - spec/lib/usps/imis/business_object_spec.rb
71
114
  - spec/lib/usps/imis/config_spec.rb