Sha256: 82f19c194ae5314cecf5110759875f88baf707af733a18c0148ce24b447e617b

Contents?: true

Size: 1.19 KB

Versions: 10

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module ChartMogul
  module API
    module Actions
      module Custom
        def self.included(base)
          base.extend ClassMethods
        end

        def custom_without_assign!(http_method, http_path, body_data = {})
          self.class.custom_without_assign!(http_method, http_path, body_data)
        end

        def custom!(http_method, http_path, body_data = {})
          json = custom_without_assign!(http_method, http_path, body_data)
          assign_all_attributes(json)
        end

        module ClassMethods
          def custom_without_assign!(http_method, http_path, body_data = {})
            resp = handling_errors do
              connection.send(http_method, http_path) do |req|
                req.headers['Content-Type'] = 'application/json'
                req.body = JSON.dump(body_data)
              end
            end
            ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
          end

          def custom!(http_method, http_path, body_data = {})
            json = custom_without_assign!(http_method, http_path, body_data)
            new_from_json(json)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
chartmogul-ruby-3.3.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-3.2.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-3.1.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-3.0.2 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-3.0.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-2.9.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-2.1.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-2.0.0 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-1.7.3 lib/chartmogul/api/actions/custom.rb
chartmogul-ruby-1.7.2 lib/chartmogul/api/actions/custom.rb