Class: CirroIOV2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cirro_io_v2/client.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  site: 'https://cirro.io/api',
  api_version: 'v2',
  auth_type: :jwt,
}.freeze
DEFINED_OPTIONS =
(DEFAULT_OPTIONS.keys + [:private_key, :private_key_path, :client_id]).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cirro_io_v2/client.rb', line 44

def initialize(options = {})
  @options = DEFAULT_OPTIONS.merge(options)

  unknown_options = @options.keys.reject { |o| DEFINED_OPTIONS.include?(o) }
  raise ArgumentError, "Unknown option(s) given: #{unknown_options}" unless unknown_options.empty?

  # TODO: for now we only have jwt
  case @options[:auth_type]
  when :jwt
    private_key = OpenSSL::PKey::RSA.new(@options[:private_key]) if @options[:private_key]
    private_key = OpenSSL::PKey::RSA.new(File.read(@options[:private_key_path])) if @options[:private_key_path]
    @request_client = RequestClients::Jwt.new(base_url: "#{@options[:site]}/#{@options[:api_version]}",
                                              client_id: @options[:client_id],
                                              private_key:)
  else
    raise ArgumentError, 'Options: ":auth_type" must be ":jwt"'
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



34
35
36
# File 'lib/cirro_io_v2/client.rb', line 34

def options
  @options
end

#request_clientObject

Returns the value of attribute request_client.



33
34
35
# File 'lib/cirro_io_v2/client.rb', line 33

def request_client
  @request_client
end

Instance Method Details

#EpamHeroesBadgesObject



126
127
128
# File 'lib/cirro_io_v2/client.rb', line 126

def EpamHeroesBadges
  Resources::EpamHeroes::Badges.new(self)
end

#GigObject



78
79
80
# File 'lib/cirro_io_v2/client.rb', line 78

def Gig
  Resources::Gig.new(self)
end

#GigInvitationObject



74
75
76
# File 'lib/cirro_io_v2/client.rb', line 74

def GigInvitation
  Resources::GigInvitation.new(self)
end

#GigResultObject



82
83
84
# File 'lib/cirro_io_v2/client.rb', line 82

def GigResult
  Resources::GigResult.new(self)
end

#GigTimeActivityObject



86
87
88
# File 'lib/cirro_io_v2/client.rb', line 86

def GigTimeActivity
  Resources::GigTimeActivity.new(self)
end

#NotificationBroadcastObject



94
95
96
# File 'lib/cirro_io_v2/client.rb', line 94

def NotificationBroadcast
  Resources::NotificationBroadcast.new(self)
end

#NotificationConfigurationObject



106
107
108
# File 'lib/cirro_io_v2/client.rb', line 106

def NotificationConfiguration
  Resources::NotificationConfiguration.new(self)
end

#NotificationLayoutObject



114
115
116
# File 'lib/cirro_io_v2/client.rb', line 114

def NotificationLayout
  Resources::NotificationLayout.new(self)
end

#NotificationLayoutTemplateObject



110
111
112
# File 'lib/cirro_io_v2/client.rb', line 110

def NotificationLayoutTemplate
  Resources::NotificationLayoutTemplate.new(self)
end

#NotificationLocaleObject



118
119
120
# File 'lib/cirro_io_v2/client.rb', line 118

def NotificationLocale
  Resources::NotificationLocale.new(self)
end

#NotificationTemplateObject



122
123
124
# File 'lib/cirro_io_v2/client.rb', line 122

def NotificationTemplate
  Resources::NotificationTemplate.new(self)
end

#NotificationTopicObject



102
103
104
# File 'lib/cirro_io_v2/client.rb', line 102

def NotificationTopic
  Resources::NotificationTopic.new(self)
end

#NotificationTopicPreferenceObject



98
99
100
# File 'lib/cirro_io_v2/client.rb', line 98

def NotificationTopicPreference
  Resources::NotificationTopicPreference.new(self)
end

#PayoutObject



90
91
92
# File 'lib/cirro_io_v2/client.rb', line 90

def Payout
  Resources::Payout.new(self)
end

#SpaceInvitationObject



70
71
72
# File 'lib/cirro_io_v2/client.rb', line 70

def SpaceInvitation
  Resources::SpaceInvitation.new(self)
end

#UserObject

resources rubocop:disable Naming/MethodName



66
67
68
# File 'lib/cirro_io_v2/client.rb', line 66

def User
  Resources::User.new(self)
end