Class: Minitel::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(telex_url) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/minitel/client.rb', line 8

def initialize(telex_url)
  unless telex_url.start_with? "https://"
    raise ArgumentError, "Bad Url"
  end
  self.connection = Excon.new(telex_url,
    :headers => {
      "User-Agent" => "minitel/#{Minitel::VERSION} excon/#{Excon::VERSION}",
      "Content-Type" => "application/json"
    }
  )
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



6
7
8
# File 'lib/minitel/client.rb', line 6

def connection
  @connection
end

Instance Method Details

#add_followup(args) ⇒ Object



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

def add_followup(args)
  StrictArgs.enforce(args, [:message_uuid, :body], [], :message_uuid)
  followup = { body: args[:body] }
  post("/producer/messages/#{args[:message_uuid]}/followups", followup)
end

#notify_app(args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/minitel/client.rb', line 20

def notify_app(args)
  StrictArgs.enforce(args, [:app_uuid, :body, :title], [:action], :app_uuid)
  if action = args[:action]
    StrictArgs.enforce(action, [:label, :url])
  end
  post_message('app', args[:app_uuid], args[:title], args[:body], action)
end

#notify_user(args) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/minitel/client.rb', line 28

def notify_user(args)
  StrictArgs.enforce(args, [:user_uuid, :body, :title], [:action], :user_uuid)
  if action = args[:action]
    StrictArgs.enforce(action, [:label, :url])
  end
  post_message('user', args[:user_uuid], args[:title], args[:body], action)
end