Sha256: 9b6123b3da43ba4cd66655e5fe5418e6c5635323afaefd76a914d63b9e29db0d
Contents?: true
Size: 1.05 KB
Versions: 10
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module SolidusBolt module Webhooks class CreateService < SolidusBolt::BaseService attr_reader :division_public_id, :event, :url def initialize(event:, url:) @event = event @url = url @division_public_id = SolidusBolt::BoltConfiguration.fetch.division_public_id super end def call create end private def create options = build_options handle_result( HTTParty.post( "#{api_base_url}/#{api_version}/webhooks", options ) ) end def build_options { body: { division_id: division_public_id, url: url }.merge(event_fields).to_json, headers: { 'Content-Type' => 'application/json' }.merge(authentication_header) } end def event_fields if event == 'all' { event_group: event } else { events: [event] } end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems