Class: FinanceSync::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/finance_sync.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/finance_sync.rb', line 14

def initialize(params)
  @services_url = params[:services_url]
  @version = params[:version]
  @user = params[:user]
  @password = params[:password]
  @auth_type = params[:auth_type] || :new
  raise ArgumentError if @user.nil? or @password.nil?
  raise TypeError unless @version.is_a? Fixnum

  @error = nil
  @conflicts = []
end

Instance Attribute Details

#auth_typeObject

Returns the value of attribute auth_type.



12
13
14
# File 'lib/finance_sync.rb', line 12

def auth_type
  @auth_type
end

#conflictsObject (readonly)

Returns the value of attribute conflicts.



11
12
13
# File 'lib/finance_sync.rb', line 11

def conflicts
  @conflicts
end

#entitiesObject (readonly)

Returns the value of attribute entities.



11
12
13
# File 'lib/finance_sync.rb', line 11

def entities
  @entities
end

#errorObject (readonly)

Returns the value of attribute error.



11
12
13
# File 'lib/finance_sync.rb', line 11

def error
  @error
end

#versionObject (readonly)

Returns the value of attribute version.



11
12
13
# File 'lib/finance_sync.rb', line 11

def version
  @version
end

Instance Method Details

#synchronize(data = {}) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/finance_sync.rb', line 27

def synchronize(data={})
  data = request_sync(data)
  return false if data == false
  @version = data['version']
  @entities = data['data']
  @conflicts = data['conflicts']
  return true
end