Class: OrionX::Endpoints::User

Inherits:
Object
  • Object
show all
Defined in:
lib/orionx/endpoints/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ User

Returns a new instance of User.



4
5
6
7
# File 'lib/orionx/endpoints/user.rb', line 4

def initialize(api_client)
  @api = api_client
  @logger = api_client.logger
end

Instance Method Details

#me ⇒ Object

Get current user information



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/orionx/endpoints/user.rb', line 10

def me
  query = "    query sdk_getMe {\n      me {\n        _id\n        email\n        name\n        profile {\n          fullName\n          phone\n          birthdate\n          countryCode\n          occupation\n          address\n        }\n      }\n    }\n  GRAPHQL\n\n  @logger.debug(\"Fetching user profile\")\n  response = @api.call(query)\n  \n  result = response.dig(\"me\")\n  @logger.info(\"User profile retrieved successfully\") if result\n  result\nend\n"

#user_id ⇒ Object

Get user ID only



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/orionx/endpoints/user.rb', line 38

def user_id
  query = "    query sdk_getUserId {\n      me {\n        _id\n      }\n    }\n  GRAPHQL\n\n  @logger.debug(\"Fetching user ID\")\n  response = @api.call(query)\n  response.dig(\"me\", \"_id\")\nend\n"