Class: Square::Connect::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/square/connect/node.rb

Direct Known Subclasses

BankAccount, Merchant, Payment, Settlement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) {|attributes| ... } ⇒ Node

Returns a new instance of Node.

Yields:

  • (attributes)


6
7
8
9
10
11
12
# File 'lib/square/connect/node.rb', line 6

def initialize(*args)
  attributes = args.extract_options!
  self.identifier = attributes[:id] || attributes[:identifier] || args.first
  self.access_token = tokenize attributes[:access_token] || args.second
  yield attributes if block_given?
  self.endpoint ||= endpoint_for identifier
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



4
5
6
# File 'lib/square/connect/node.rb', line 4

def access_token
  @access_token
end

#endpointObject

Returns the value of attribute endpoint.



4
5
6
# File 'lib/square/connect/node.rb', line 4

def endpoint
  @endpoint
end

#identifierObject

Returns the value of attribute identifier.



4
5
6
# File 'lib/square/connect/node.rb', line 4

def identifier
  @identifier
end

Instance Method Details

#fetchObject



14
15
16
17
18
19
20
21
22
# File 'lib/square/connect/node.rb', line 14

def fetch
  access_token_required!
  attributes = handle_response do
    access_token.get endpoint
  end
  self.class.new attributes.merge(
    access_token: access_token
  )
end