Sha256: 64ca38a73e2c739ef83a4241e46eb4d35ab97464b0a01e424f7eefadac7e27a8

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 KB

Contents

require 'rubygems'
require 'ruby-fs-stack/fs_communicator'
# Including more than one enunciate library raises a warning of
# already initialized constant.
require 'ruby-fs-stack/warning_suppressor'
with_warnings_suppressed do
  require 'ruby-fs-stack/enunciate/identity'
end

module IdentityV1
  
  # This method gets mixed into the FsCommunicator so that
  # you can make calls on the fs_familytree_v1 module
  def identity_v1
    @identity_v1_com ||= Communicator.new self # self at this point refers to the FsCommunicator instance
  end
  
  class Communicator
    Base = '/identity/v1/'
    
    # ====params
    # fs_communicator: FsCommunicator instance
    def initialize(fs_communicator)
      @communicator = fs_communicator
    end
    
    # ==== Params
    # <tt>credentials</tt> - :username, :password
    def authenticate(credentials = {})
      url = Base + 'login'
      response = @communicator.get(url, credentials)
      login_result = Org::Familysearch::Ws::Identity::V1::Schema::Identity.from_json JSON.parse(response.body)
      if login_result.statusCode == 200
        @communicator.session = login_result.session.id
        return true
      end
    end
  end
  
end

# Mix in the module so that the identity_v1 can be called
class FsCommunicator
  include IdentityV1
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
ruby-fs-stack-0.4.12 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.11 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.10 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.9 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.8 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.7 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.6 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.5 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.4 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.3 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.2 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.4.0 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.3.3 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.3.2 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.3.0 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.2.6 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.2.5 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.2.4 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.2.3 lib/ruby-fs-stack/identity.rb
ruby-fs-stack-0.2.2 lib/ruby-fs-stack/identity.rb