Class: Mpayer::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/mpayer_ruby/endpoints/_endpoint.rb

Direct Known Subclasses

Account, Client, Message, Payable, Transaction

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: nil, **keyword_args) ⇒ Endpoint

Mpayer::Model.new(options={})



7
8
9
10
11
12
13
14
15
16
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 7

def initialize(config:nil,**keyword_args)
	@attributes = Hashie::Mash.new(keyword_args)
	keyword_args.each do |k,v|
		self.send("#{k.to_s}=",v) rescue nil
	end
	@config = set_config(config)
   # @is_new ||= true
   @pagination  ||= {}
   after_initialize
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (protected)



94
95
96
97
98
99
100
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 94

def method_missing(m, *args, &block)
	if @response.is_a?(Hash)
		@response.keys.include?(m.to_s) ? @response.send(m) : super
	else
		super
	end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 3

def attributes
  @attributes
end

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 3

def config
  @config
end

#endpointObject

Returns the value of attribute endpoint.



3
4
5
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 3

def endpoint
  @endpoint
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 4

def id
  @id
end

#paginationObject

Returns the value of attribute pagination.



3
4
5
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 3

def pagination
  @pagination
end

#responseObject

Returns the value of attribute response.



3
4
5
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 3

def response
  @response
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mpayer_ruby/endpoints/_endpoint.rb', line 23

def success?
	!response.code.to_s.match(/\A2\d+/).to_s.empty? rescue false
end