Class: IdentityV2::Communicator

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-fs-stack/identity/communicator.rb

Constant Summary collapse

Base =
'/identity/v2/'

Instance Method Summary collapse

Constructor Details

#initialize(fs_communicator) ⇒ Communicator

params

fs_communicator: FsCommunicator instance



21
22
23
# File 'lib/ruby-fs-stack/identity/communicator.rb', line 21

def initialize(fs_communicator)
  @communicator = fs_communicator
end

Instance Method Details

#authenticate(credentials = {}) ⇒ Object Also known as: login

Params

credentials - :username, :password



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ruby-fs-stack/identity/communicator.rb', line 27

def authenticate(credentials = {})
  url = Base + 'login'
  response = @communicator.get(url, credentials)
  if response.code == '200'
     = Org::Familysearch::Ws::Identity::V2a::Schema::Identity.from_json JSON.parse(response.body)
    @communicator.session = .session.id
    return true
  else
    return false
  end
end