Sha256: e96d711c151051029da32b7cd876614ca0497f7f25cd6259a29b7b6597af0947
Contents?: true
Size: 1.02 KB
Versions: 4
Compression:
Stored size: 1.02 KB
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 @body = IronBank.client.connection.post(endpoint, params).body raise ::IronBank::UnprocessableEntityError, errors unless success? IronBank::Object.new(body).deep_underscore end private attr_reader :args, :body def initialize(args) @args = args end def endpoint "v1/action/#{name.downcase}" end def name self.class.name.split("::").last end def success? response_object.fetch(:success, true) end def response_object @response_object ||= if body.is_a?(Array) ::IronBank::Object.new(body.first).deep_underscore else {} end end def errors { errors: response_object.fetch(:errors, []) } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
iron_bank-5.4.1 | lib/iron_bank/action.rb |
iron_bank-5.4.0 | lib/iron_bank/action.rb |
iron_bank-5.3.2 | lib/iron_bank/action.rb |
iron_bank-5.3.0 | lib/iron_bank/action.rb |