Module: Msgraph::Api

Defined in:
lib/msgraph/api.rb,
lib/msgraph/api/client.rb,
lib/msgraph/api/errors.rb,
lib/msgraph/api/railtie.rb,
lib/msgraph/api/version.rb,
lib/msgraph/api/resource/base.rb,
lib/msgraph/api/resource/list.rb,
lib/msgraph/api/resource/user.rb,
lib/msgraph/api/resource/message.rb,
lib/msgraph/api/resource/mail_folder.rb,
lib/msgraph/api/non_multipart_interceptor.rb

Defined Under Namespace

Modules: Resource Classes: Client, IndexExceedsPageError, IndexUndercutsPageError, MissingConfigError, NonMultipartInterceptor, Railtie

Constant Summary collapse

VERSION =
"0.0.5"

Class Method Summary collapse

Class Method Details

.open(settings_or_filepath = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/msgraph/api.rb', line 19

def self.open(settings_or_filepath=nil)
  case settings_or_filepath
  when nil
    if defined?(ActionMailer)
      settings = ActionMailer::Base.microsoft_graph_settings
    else
      path = File.join(Dir.getwd, "settings.yml")
      settings = settings_from_file(path)
    end
  when String
    settings = settings_from_file(settings_or_filepath)
  when Hash
    settings = settings_or_filepath
  else
    raise NotImplementedException, "#{settings_or_filepath.class.name} not supported as settings for msgraph-api"
  end
  Client.new(settings)
end

.settings_from_file(path) ⇒ Object



38
39
40
41
42
# File 'lib/msgraph/api.rb', line 38

def self.settings_from_file(path)
  return nil unless File.exist?(path)
  text = File.read(path)
  YAML.safe_load(text, symbolize_names: true)
end