class IronBank::Action
Base class for Zuora actions, e.g., subscribe
Attributes
args[R]
body[R]
Public Class Methods
call(args)
click to toggle source
# File lib/iron_bank/action.rb, line 9 def self.call(args) new(args).call end
new(args)
click to toggle source
# File lib/iron_bank/action.rb, line 25 def initialize(args) @args = args end
Public Instance Methods
call()
click to toggle source
# File lib/iron_bank/action.rb, line 13 def call @body = IronBank.client.connection.post(endpoint, params).body raise ::IronBank::UnprocessableEntityError, errors unless success? IronBank::Object.new(body).deep_underscore end
Private Instance Methods
endpoint()
click to toggle source
# File lib/iron_bank/action.rb, line 29 def endpoint "v1/action/#{name.downcase}" end
errors()
click to toggle source
# File lib/iron_bank/action.rb, line 51 def errors { errors: response_object.fetch(:errors, []) } end
name()
click to toggle source
# File lib/iron_bank/action.rb, line 33 def name self.class.name.split("::").last end
response_object()
click to toggle source
# File lib/iron_bank/action.rb, line 41 def response_object @response_object ||= begin if body.is_a?(Array) ::IronBank::Object.new(body.first).deep_underscore else {} end end end
success?()
click to toggle source
# File lib/iron_bank/action.rb, line 37 def success? response_object.fetch(:success, true) end