class Etwin::Oauth::ShortOauthClient

OAuth client with minimum data to identify and display it

Attributes

display_name[R]
id[R]
key[R]

Public Class Methods

deserialize(raw) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 94
def deserialize(raw)
  id = OauthClientId.new(raw['id'])
  raw_key = raw['key']
  key = raw_key.nil? ? nil : OauthClientKey.new(raw_key)
  display_name = OauthClientDisplayName.new(raw['display_name'])
  new(id, key, display_name)
end
from_json(json_str) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 89
def from_json(json_str)
  deserialize JSON.parse(json_str)
end
new(id, key, display_name) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 23
def initialize(id, key, display_name)
  @id = T.let(id, OauthClientId)
  @key = T.let(key, T.nilable(OauthClientKey))
  @display_name = T.let(display_name, OauthClientDisplayName)
  freeze
end

Public Instance Methods

==(other) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 31
def ==(other)
  case other
  when ShortOauthClient
    @id == other.id && @key == other.key && @display_name == other.display_name
  else
    false
  end
end
as_json() click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 52
def as_json
  {
    'id' => @id.as_json,
    'key' => @key.nil? ? nil : @key.as_json,
    'display_name' => @display_name.as_json
  }
end
hash() click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 41
def hash
  [@id, @key, @display_name].hash
end
inspect() click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 61
def inspect
  PP.singleline_pp(self, String.new)
end
pretty_print(pp) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 66
def pretty_print(pp)  # rubocop:disable Metrics/MethodLength
  pp.group(0, "#{self.class.name}(", ')') do
    pp.nest 1 do
      pp.breakable ''
      pp.text 'id='
      pp.pp @id
      pp.text ','
      pp.breakable ''
      pp.text 'key='
      pp.pp @key
      pp.text ','
      pp.breakable ''
      pp.text 'display_name='
      pp.pp @display_name
    end
    pp.breakable ''
  end
end
to_json(opts = nil) click to toggle source
# File lib/etwin/oauth/short_oauth_client.rb, line 47
def to_json(opts = nil)
  JSON.generate(as_json, opts)
end