elibom 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/elibom/client.rb +16 -24
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmViYjhiNDg0MWQwZmI4NzdjNDhiZWI2NTA4OThiYTBmMGI2MjRjZQ==
4
+ NDYzMDI2YmRhZDNiZDUwOWIyNmQ0MjFhNTdlMmNlNTRiOGRiODEwNA==
5
5
  data.tar.gz: !binary |-
6
- ZGFjZDdhYjM0OTJhNGYwMGM5NjU5MjMwOTI4MTY1NDYyYjc1MWM3Yg==
6
+ YTNkZGJhN2VkNjI2NjI0YjU0ZGVlNWVhZGQ5MzI3YjgwNjZjZjY2Mg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDU2YTc3MDNlZjQyOGExNDQwZmNiNjJiMGFjMTUzMjk2NGJmN2ZjNDVmZDhl
10
- ODM4NmE2NWMwNmRjZmFmNmRmODZhMDdlYTIyMzg5NWI0MTRkMDczOWJiY2Zh
11
- MDhjZWRhYmNiZDVmYWE5ZTA4OTIyMTNkODEzN2NjNTMwNWNlM2I=
9
+ NGI4ODYxZTgwZjYzMDNlYmI3ZThkYjVjODI3YjM5MjBkYjhmNWNhNThlNDk1
10
+ N2FmNzZjNWQwNmQ0YmU4NzZjNzFiZmUyZTA5NWQ5YjVjMGRkMTAxYjBkOWRl
11
+ MjZjY2Q0Mjk1NTc5YTUzOGNiMDM0MTA2MWY4OTcwNGVmN2ZiMDg=
12
12
  data.tar.gz: !binary |-
13
- OGViYjhiZDEyMzQ1Y2UzNWMxNmZmNTU4ZGQyYjU0NTlkZjZhMTEwNDU3Mjli
14
- OGQxODc5ODU5NWI3NjRlNTk1MmE5NTgyMDMwMzBiYzc2ZjdiNmYyZTkxMmEz
15
- Zjc1OTVkOGFmODZkN2Y3ZjY4ZjU1MDFkM2M2N2RiZmZmNTcyNTc=
13
+ Yzc0N2IyYWFmMTY2YjZiZGFmNzA5YjU4ZTVjOWFhZDZmNGMyYjk5NjUxZGJi
14
+ NWRlOGNmYmRjMTkxMTRlOThjNmE0NDBkMTk4ZWQzYTAwOTJhOTVmY2JiZTgz
15
+ NTQ4YTZmMTBmODEyN2I2MDI0YjViNzk1MDIyMDk4OTY4YWE0NDQ=
data/lib/elibom/client.rb CHANGED
@@ -16,51 +16,43 @@ module Elibom
16
16
  end
17
17
 
18
18
  def send_message(args={})
19
- body = {}
20
-
21
- required_args = [:to, :text]
22
- required_args.each do |arg|
23
- raise ArgumentError, "Missing key ':#{arg}'" if args[arg].nil?
24
- body[arg] = args[arg]
25
- end
19
+ raise ArgumentError, "No args provided" if args.nil?
20
+ raise ArgumentError, "Missing key ':to'" if args[:to].nil?
21
+ raise ArgumentError, "Missing key ':text'" if args[:text].nil?
22
+ raise ArgumentError, "Text is too long, max 160 characters" if args[:text].length > 160
26
23
 
24
+ body = { "to" => args[:to], "text" => args[:text] }
27
25
  post '/messages', body
28
26
  end
29
27
 
30
28
  def schedule_message(args={})
31
- body = {}
32
-
33
- required_args = [:to, :text]
34
- required_args.each do |arg|
35
- raise ArgumentError, "Missing key ':#{arg}'" if args[arg].nil?
36
- body[arg] = args[arg]
37
- end
38
-
29
+ raise ArgumentError, "No args provided" if args.nil?
30
+ raise ArgumentError, "Missing key ':to'" if args[:to].nil?
31
+ raise ArgumentError, "Missing key ':text'" if args[:text].nil?
32
+ raise ArgumentError, "Invalid argument ':text'. Too long, max 160 characters" if args[:text].length > 160
39
33
  raise ArgumentError, "Missing key ':schedule_date'" if args[:schedule_date].nil?
40
34
  raise ArgumentError, "Invalid argument ':schedule_date'" unless args[:schedule_date].respond_to?('strftime')
41
35
 
42
- body['scheduleDate'] = args[:schedule_date].strftime('%Y-%m-%d %H:%M')
43
-
36
+ body = { "to" => args[:to], "text" => args[:text], "scheduleDate" => args[:schedule_date].strftime('%Y-%m-%d %H:%M') }
44
37
  post '/messages', body
45
38
  end
46
39
 
47
- def messages(delivery_id)
40
+ def show_delivery(delivery_id)
48
41
  raise ArgumentError, "'delivery_id' cannot be nil or empty" if delivery_id.nil? || delivery_id.empty?
49
42
  get "/messages/#{delivery_id}"
50
43
  end
51
- alias :list_messages :messages
44
+ alias :delivery :show_delivery
52
45
 
53
- def scheduled
46
+ def scheduled_messages
54
47
  get "/schedules/scheduled"
55
48
  end
56
- alias :list_scheduled_messages :scheduled
57
- alias :schedules :scheduled
58
- alias :list_schedules :scheduled
49
+ alias :list_scheduled_messages :scheduled_messages
59
50
 
60
- def show_schedule(schedule_id)
51
+ def show_scheduled_message(schedule_id)
61
52
  raise ArgumentError, "'schedule_id' cannot be nil" if schedule_id.nil?
62
53
  get "/schedules/#{schedule_id}"
63
54
  end
55
+ alias :scheduled_message :show_scheduled_message
64
56
 
65
57
  def cancel_schedule(schedule_id)
66
58
  raise ArgumentError, "'schedule_id' cannot be nil" if schedule_id.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - German Escobar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-06 00:00:00.000000000 Z
11
+ date: 2013-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json