portatext 1.5.10 → 1.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/portatext.rb +1 -0
- data/lib/portatext/command/api/sounds.rb +67 -0
- data/lib/portatext/command/base.rb +6 -0
- data/portatext.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf0232edbd09b5ccb65d88ebd36d936e13a820b4
|
4
|
+
data.tar.gz: 9d96c246c39482fa2e92b3f7d981ce9ed80af5d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1bfdfc131867114b23ebbaada023fff242f4f7ac0c4f683c5579a4f9811dfab846f233ed57b53fb2968b5c58f9703e22f93a836b69d58cc07e41fa5c3a94e40
|
7
|
+
data.tar.gz: 04822b0061add91bf150a8ff8fa9ea4a418e9916b56bc00692fded5f41ae2c135eb58044cf366506455be9e8a5d6521c18abf7126bfb19c7b62001dd911f0fe3
|
data/lib/portatext.rb
CHANGED
@@ -45,6 +45,7 @@ require_relative 'portatext/command/api/destinations'
|
|
45
45
|
require_relative 'portatext/command/api/simulate'
|
46
46
|
require_relative 'portatext/command/api/summary'
|
47
47
|
require_relative 'portatext/command/api/gsm_charset'
|
48
|
+
require_relative 'portatext/command/api/sounds'
|
48
49
|
|
49
50
|
# The PortaText namespace.
|
50
51
|
#
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module PortaText
|
2
|
+
module Command
|
3
|
+
module Api
|
4
|
+
# The sounds endpoint.
|
5
|
+
# https://github.com/PortaText/docs/wiki/REST-API#api_sounds
|
6
|
+
#
|
7
|
+
# Author:: Marcelo Gornstein (mailto:marcelog@portatext.com)
|
8
|
+
# Copyright:: Copyright (c) 2015 PortaText
|
9
|
+
# License:: Apache-2.0
|
10
|
+
class Sounds < Base
|
11
|
+
def id(id)
|
12
|
+
set :id, id
|
13
|
+
end
|
14
|
+
|
15
|
+
def name(name)
|
16
|
+
set :name, name
|
17
|
+
end
|
18
|
+
|
19
|
+
def description(description)
|
20
|
+
set :description, description
|
21
|
+
end
|
22
|
+
|
23
|
+
def save_to(file)
|
24
|
+
set :accept_sound_file, file
|
25
|
+
end
|
26
|
+
|
27
|
+
def sound(file)
|
28
|
+
set :sound_file, file
|
29
|
+
end
|
30
|
+
|
31
|
+
def body(_method)
|
32
|
+
return "file:#{@args[:sound_file]}" unless @args[:sound_file].nil?
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/MethodLength
|
37
|
+
# rubocop:disable Metrics/AbcSize
|
38
|
+
def endpoint(_method)
|
39
|
+
endpoint = 'sounds'
|
40
|
+
id = @args[:id]
|
41
|
+
@args.delete :id
|
42
|
+
|
43
|
+
endpoint = "#{endpoint}/#{id}" unless id.nil?
|
44
|
+
|
45
|
+
qs = {}
|
46
|
+
unless @args[:description].nil?
|
47
|
+
qs['description'] = @args[:description]
|
48
|
+
@args.delete :description
|
49
|
+
end
|
50
|
+
|
51
|
+
unless @args[:name].nil?
|
52
|
+
qs['name'] = @args[:name]
|
53
|
+
@args.delete :name
|
54
|
+
end
|
55
|
+
|
56
|
+
unless qs.empty?
|
57
|
+
qs = URI.encode_www_form qs
|
58
|
+
return "#{endpoint}?#{qs}"
|
59
|
+
end
|
60
|
+
endpoint
|
61
|
+
end
|
62
|
+
# rubocop:enable Metrics/AbcSize
|
63
|
+
# rubocop:enable Metrics/MethodLength
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -37,12 +37,14 @@ module PortaText
|
|
37
37
|
|
38
38
|
def content_type(_method)
|
39
39
|
return 'text/csv' unless @args[:file].nil?
|
40
|
+
return 'audio/mpeg' unless @args[:sound_file].nil?
|
40
41
|
'application/json'
|
41
42
|
end
|
42
43
|
|
43
44
|
def accept_content_type(_method)
|
44
45
|
return '*/*' unless @args[:accept_any_file].nil?
|
45
46
|
return 'text/csv' unless @args[:accept_file].nil?
|
47
|
+
return 'audio/mpeg' unless @args[:accept_sound_file].nil?
|
46
48
|
'application/json'
|
47
49
|
end
|
48
50
|
|
@@ -58,18 +60,22 @@ module PortaText
|
|
58
60
|
|
59
61
|
private
|
60
62
|
|
63
|
+
# rubocop:disable Metrics/MethodLength
|
61
64
|
def run(method)
|
62
65
|
a_type = accept_content_type method
|
63
66
|
command_endpoint = endpoint(method)
|
64
67
|
file = @args[:accept_file]
|
65
68
|
file ||= @args[:accept_any_file]
|
69
|
+
file ||= @args[:accept_sound_file]
|
66
70
|
@args.delete :accept_file
|
67
71
|
@args.delete :accept_any_file
|
72
|
+
@args.delete :accept_sound_file
|
68
73
|
@client.run(
|
69
74
|
command_endpoint, method, content_type(method),
|
70
75
|
a_type, body(method), file
|
71
76
|
)
|
72
77
|
end
|
78
|
+
# rubocop:enable Metrics/MethodLength
|
73
79
|
end
|
74
80
|
end
|
75
81
|
end
|
data/portatext.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portatext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PortaText
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/portatext/command/api/simulate.rb
|
165
165
|
- lib/portatext/command/api/sms.rb
|
166
166
|
- lib/portatext/command/api/sms_campaign.rb
|
167
|
+
- lib/portatext/command/api/sounds.rb
|
167
168
|
- lib/portatext/command/api/summary.rb
|
168
169
|
- lib/portatext/command/api/tariffs.rb
|
169
170
|
- lib/portatext/command/api/templates.rb
|