Sha256: fc8ff3cd32409ebcc14157b65b0b246014c80c500db8e25bd89895ec37755356

Contents?: true

Size: 660 Bytes

Versions: 3

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

module IronBank
  # Base class for Zuora actions, e.g., subscribe
  #
  class Action
    private_class_method :new

    def self.call(args)
      new(args).call
    end

    def call
      IronBank.client.connection.post(endpoint, params).body
    end

    private

    attr_reader :args

    def initialize(args)
      @args = args
    end

    def endpoint
      "v1/action/#{name.downcase}"
    end

    def name
      self.class.name.split('::').last
    end

    def requests(type: :upper)
      args.fetch(:objects).map do |object|
        IronBank::Object.new(object).deep_camelize(type: type)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iron_bank-1.0.1 lib/iron_bank/action.rb
iron_bank-1.0.0 lib/iron_bank/action.rb
iron_bank-0.7.1 lib/iron_bank/action.rb