Class: Velix::Client

Inherits:
Object
  • Object
show all
Includes:
Retry
Defined in:
lib/velix/client.rb

Constant Summary collapse

USER_AGENT =
"velix-ruby-sdk/0.1.0.pre.alpha1"

Constants included from Retry

Retry::IDEMPOTENT_METHODS, Retry::RETRYABLE_STATUSES

Instance Method Summary collapse

Methods included from Retry

#with_retry

Constructor Details

#initialize(api_url:, api_key:, timeout: 30, max_retries: 3) ⇒ Client

Returns a new instance of Client.



23
24
25
26
# File 'lib/velix/client.rb', line 23

def initialize(api_url:, api_key:, timeout: 30, max_retries: 3)
  @config = Config.new(api_url: api_url, api_key: api_key,
                       timeout: timeout, max_retries: max_retries)
end

Instance Method Details

#checkinObject



29
# File 'lib/velix/client.rb', line 29

def checkin    = @checkin    ||= Modules::Checkin.new(self)

#delete(path) ⇒ Object



63
64
65
66
# File 'lib/velix/client.rb', line 63

def delete(path)
  uri = build_uri(path)
  request(Net::HTTP::Delete.new(uri))
end

#eventsObject



32
# File 'lib/velix/client.rb', line 32

def events     = @events     ||= Modules::Events.new(self)

#get(path, params = {}) ⇒ Object



37
38
39
40
# File 'lib/velix/client.rb', line 37

def get(path, params = {})
  uri = build_uri(path, params)
  request(Net::HTTP::Get.new(uri))
end

#lgpdObject



30
# File 'lib/velix/client.rb', line 30

def lgpd       = @lgpd       ||= Modules::Lgpd.new(self)

#meObject



31
# File 'lib/velix/client.rb', line 31

def me         = @me         ||= Modules::Me.new(self)

#onboardingObject



28
# File 'lib/velix/client.rb', line 28

def onboarding = @onboarding ||= Modules::Onboarding.new(self)

#patch(path, body = {}) ⇒ Object



56
57
58
59
60
61
# File 'lib/velix/client.rb', line 56

def patch(path, body = {})
  uri = build_uri(path)
  req = Net::HTTP::Patch.new(uri)
  req.body = body.to_json
  request(req)
end

#post(path, body = {}) ⇒ Object



42
43
44
45
46
47
# File 'lib/velix/client.rb', line 42

def post(path, body = {})
  uri = build_uri(path)
  req = Net::HTTP::Post.new(uri)
  req.body = body.to_json
  request(req)
end

#put(path, body = {}) ⇒ Object



49
50
51
52
53
54
# File 'lib/velix/client.rb', line 49

def put(path, body = {})
  uri = build_uri(path)
  req = Net::HTTP::Put.new(uri)
  req.body = body.to_json
  request(req)
end

#timeObject

Velix Time has no endpoint under /v1/api/* yet — see modules/time.rb.



35
# File 'lib/velix/client.rb', line 35

def time = @time ||= Modules::Time.new(self)