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.



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

def initialize(telex_url)
  unless telex_url.start_with? "https://"
    raise ArgumentError, "Bad Url"
  end
  @uri = URI.parse(telex_url)
  @user = @uri.user
  @password = @uri.password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/minitel/client.rb', line 9

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri.



9
10
11
# File 'lib/minitel/client.rb', line 9

def uri
  @uri
end

#userObject (readonly)

Returns the value of attribute user.



9
10
11
# File 'lib/minitel/client.rb', line 9

def user
  @user
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