Class: LedgerSync::Adaptors::Test::Adaptor

Inherits:
Adaptor
  • Object
show all
Defined in:
lib/ledger_sync/adaptors/test/adaptor.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Adaptor

#adaptor_configuration, #base_module, config, #ledger_attributes_to_save, #parse_operation_error, #searcher_for?, #searcher_klass_for, url_for

Methods included from Validatable

#valid?, #validate, #validate_or_fail

Constructor Details

#initialize(*_config) ⇒ Adaptor

Returns a new instance of Adaptor.



5
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 5

def initialize(*_config); end

Class Method Details

.ledger_attributes_to_saveObject



41
42
43
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 41

def self.ledger_attributes_to_save
  []
end

Instance Method Details

#find(resource:, id:) ⇒ Object



7
8
9
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 7

def find(resource:, id:)
  { 'id' => id }
end

#post(resource:, payload:) ⇒ Object



11
12
13
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 11

def post(resource:, payload:)
  payload
end

#query(resource:, query:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 15

def query(resource:, query:)
  resource_klass = LedgerSync.resources[resource.to_sym]

  Array.new(2) do |i|
    ret = {
      'id' => SecureRandom.uuid,
    }

    ret['name'] = "Test #{resource} #{i}" if resource_klass.instance_methods.include?(:name=)
    ret
  end
end

#refresh!Object



28
29
30
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 28

def refresh!
  self
end

#url_for(resource:) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/ledger_sync/adaptors/test/adaptor.rb', line 32

def url_for(resource:)
  case resource
  when LedgerSync::Customer
    "http://example.com/customer/#{resource.ledger_id}"
  else
    raise NotImplementedError
  end
end