Class: IdentityV2::Communicator
- Defined in:
- lib/ruby-fs-stack/identity/communicator.rb
Constant Summary collapse
- Base =
'/identity/v2/'
Instance Method Summary collapse
-
#authenticate(credentials = {}) ⇒ Object
(also: #login)
Params
credentials
- :username, :password. -
#initialize(fs_communicator) ⇒ Communicator
constructor
params fs_communicator: FsCommunicator instance.
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' login_result = Org::Familysearch::Ws::Identity::V2a::Schema::Identity.from_json JSON.parse(response.body) @communicator.session = login_result.session.id return true else return false end end |