class BingAdsRubySdk::OAuth2::FsStore

Oauth2 token default non-encrypted File System store

Attributes

filename[R]

Public Class Methods

new(filename) click to toggle source

@param filename [String] the uniq filename to identify filename storing data.

# File lib/bing_ads_ruby_sdk/oauth2/fs_store.rb, line 8
def initialize(filename)
  @filename = filename
end

Public Instance Methods

read() click to toggle source

Reads the token from file @return [Hash] if the token information that was stored. @return [nil] if the file doesn't exist.

# File lib/bing_ads_ruby_sdk/oauth2/fs_store.rb, line 24
def read
  return nil unless File.file?("./#{filename}")
  JSON.parse(IO.read(filename))
end
write(value) click to toggle source

Writes the token to file @return [File] if the file was written (doesn't mean the token is). @return [self] if the filename don't exist.

# File lib/bing_ads_ruby_sdk/oauth2/fs_store.rb, line 15
def write(value)
  return nil unless filename
  File.open(filename, 'w') { |f| JSON.dump(value, f) }
  self
end