Module: SpecConfig
- Defined in:
- lib/k2-connect-ruby/k2_utilities/spec_modules/spec_config.rb
Constant Summary collapse
- TILL_SCOPE_EVENT_TYPES =
%[buygoods_transaction_received b2b_transaction_received buygoods_transaction_reversed]
Class Method Summary collapse
- .callback_url(context) ⇒ Object
- .custom_stub_request(request_type, path_url, request_body, response_code) ⇒ Object
Instance Method Summary collapse
- #subscription_stub_request(event_type, url) ⇒ Object
- #webhook_structure(event_type, scope, scope_reference = nil) ⇒ Object
Class Method Details
.callback_url(context) ⇒ Object
21 22 23 |
# File 'lib/k2-connect-ruby/k2_utilities/spec_modules/spec_config.rb', line 21 def callback_url(context) @specs[:callback_url][:"#{context}"] end |
.custom_stub_request(request_type, path_url, request_body, response_code) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/k2-connect-ruby/k2_utilities/spec_modules/spec_config.rb', line 25 def custom_stub_request(request_type, path_url, request_body, response_code) request_body = request_body.to_s request_uri = path_url request_headers = { Authorization: "Bearer access_token", Accept: "application/json" } if request_type.eql?('post') request_headers['Content-Type'] = 'application/json' end # Stub Request WebMock.stub_request(:"#{request_type}", request_uri) .with(headers: request_headers, body: request_body) .to_return(status: response_code) end |
Instance Method Details
#subscription_stub_request(event_type, url) ⇒ Object
6 7 8 9 |
# File 'lib/k2-connect-ruby/k2_utilities/spec_modules/spec_config.rb', line 6 def subscription_stub_request(event_type, url) request_body = { event_type: event_type, url: url, secret: 'webhook_secret' } SpecConfig.custom_stub_request('post', K2Config.path_url('webhook_subscriptions'), request_body, 200) end |
#webhook_structure(event_type, scope, scope_reference = nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/k2-connect-ruby/k2_utilities/spec_modules/spec_config.rb', line 11 def webhook_structure(event_type, scope, scope_reference = nil) { event_type: event_type, url: @callback_url, scope: scope, scope_reference: scope_reference, } end |