simple_desk 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efa031443bd5d21d0fbe7ff9b12f837f6ed2d054
4
- data.tar.gz: afda9d3ba6533a4491577969fb0b4c1b30f2af20
3
+ metadata.gz: 6b70d23fdd77697269c4c0d6b1bf33e987ed51c6
4
+ data.tar.gz: 75255aa85e2e519deebce54a7412ae9dcd3636ed
5
5
  SHA512:
6
- metadata.gz: 78f5e45da02017034e8161897d75983f87bd5ea72f3e905ad4888ac3bfdd6c6b894b755b9f3a374f3c8d16ade3d8b9ff5c2c64ba727890d7c0f74b3cbc972277
7
- data.tar.gz: 14485858a1e5dd31104544fff35a0f5b09def96cd0899a09f3b69af20818b980ab4c593b3fd725d28c939ee72b1180847a0a0e3412c68e7de1d258036bab9a7d
6
+ metadata.gz: eca9cf67e9733c8c30ecc59f0b4f7a5686016bba3625bdbe23c792339d66904400e6fbde123e8e6eb3e99efb66b8788436766ee7de59ba0fc6baf587fdf4ee45
7
+ data.tar.gz: 05496ee1873dfc428b74b0c8eba57b4069e47efc8c736f2294256ca259909980d7ca7c134deff6690960147a28e4dcca2426d83174dbbefb66f16dca585410df
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SimpleDesk
2
2
 
3
- [Simple Desk](https://www.getsimpledesk.com) is a skin on top of the twillio API which makes it much easier to use. This simple wrapper is a gem to quickly integrate with Simple Desk in seconds.
3
+ [Simple Desk](https://www.getsimpledesk.com) is an SMS customer engagement platform that allows companies to have 2-way conversations with their customers over SMS - whether it's for sales, customer service, funnel abandonment, or transactional messages.
4
4
 
5
5
  ## Installation
6
6
 
@@ -36,7 +36,15 @@ Like this:
36
36
 
37
37
  params = {phone_number: "1231231232", email: "elijah@example.com", first_name: "Elijah", last_name: "Murray"}
38
38
  SimpleDesk.add_customer(params)
39
-
39
+
40
+ You can also add any amount of additional properties like so (using phone_number as the identifier):
41
+
42
+ properties = {revenue_amount: "$100", location: "San Francisco"}
43
+ SimpleDesk.add_customer({phone_number: "1231231232"}, properties)
44
+
45
+ The gem will turn the properties into a Base64 encoded json object automatically.
46
+
47
+ You can use params and properties in the same add_customer call too!
40
48
 
41
49
  ###**Messaging**
42
50
  To message a user the format is similar
@@ -52,6 +60,7 @@ Features that still need to be implemented
52
60
  - Add ability to pass in properties and convert to base 64
53
61
  - Add auto capitalization for names
54
62
  - Parse formatting for phone number
63
+ - Update readme to explain setting up [IFTTT](https://ifttt.com/recipes/1110-send-an-sms-when-a-new-gmail-is-from-a-specific-email-address)
55
64
 
56
65
  ## Contributing
57
66
 
data/RELEASE.md CHANGED
@@ -1,3 +1,7 @@
1
+ v 0.3.4
2
+ -------
3
+ Added ability to send properties
4
+
1
5
  v 0.3.3
2
6
  -------
3
7
  Remove item from to do list in readme
@@ -1,3 +1,3 @@
1
1
  module SimpleDesk
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/lib/simple_desk.rb CHANGED
@@ -3,46 +3,58 @@ require "net/http"
3
3
  require "uri"
4
4
 
5
5
  module SimpleDesk
6
- BASE_URL = "https://www.getsimpledesk.com"
7
-
8
- def self.add_customer(params)
9
- uri = URI.parse(post_url("add_customer"))
10
- response = Net::HTTP.post_form(uri, params)
11
- end
12
- # alias_method :update_customer, :add_customer
13
-
14
- def self.message_customer(message_and_phone_number)
15
- uri = URI.parse(post_url("message_customer"))
16
- response = Net::HTTP.post_form(uri, message_and_phone_number)
17
- end
18
-
19
- private
20
- def self.build_url(post_type = nil, params=nil)
21
- url = post_url(post_type)
22
-
23
- if params
24
- string = ''
25
- url << "&"
26
- params.each { |k,v| string << "#{k}=#{v}&" }
27
-
28
- url << string
29
- url = url[0...-1] if (url[-1] == '&')
30
- end
31
-
32
- return url
33
- end
34
-
35
- def self.post_url(post_type)
36
- if post_type == nil
37
- "#{BASE_URL}?token=#{ENV['SIMPLE_DESK_TOKEN']}"
38
- else
39
- case post_type
40
- when "message_customer"
41
- "#{BASE_URL}/api_send_message?token=#{ENV['SIMPLE_DESK_TOKEN']}"
42
- when "add_customer" || "update_customer"
43
- "#{BASE_URL}/api_add_customer?token=#{ENV['SIMPLE_DESK_TOKEN']}"
44
- end
45
- end
46
- end
6
+ BASE_URL = "https://www.getsimpledesk.com"
7
+
8
+ def self.add_customer(params, customer_properties = nil)
9
+ unless customer_properties.blank?
10
+ props = Base64.urlsafe_encode64(customer_properties.to_json)
11
+ params = params.merge(properties: props)
12
+ end
13
+ url = URI.parse(post_url("add_customer"))
14
+ req = Net::HTTP::Post.new(url.request_uri)
15
+ req.set_form_data(params)
16
+ http = Net::HTTP.new(url.host, url.port)
17
+ http.use_ssl = true
18
+ response = http.request(req)
19
+ end
20
+ # alias_method :update_customer, :add_customer
21
+
22
+ def self.message_customer(message_and_phone_number)
23
+ url = URI.parse(post_url("message_customer"))
24
+ req = Net::HTTP::Post.new(url.request_uri)
25
+ req.set_form_data(message_and_phone_number)
26
+ http = Net::HTTP.new(url.host, url.port)
27
+ http.use_ssl = true
28
+ response = http.request(req)
29
+ end
30
+
31
+ private
32
+ def self.build_url(post_type = nil, params=nil)
33
+ url = post_url(post_type)
34
+
35
+ if params
36
+ string = ''
37
+ url << "&"
38
+ params.each { |k,v| string << "#{k}=#{v}&" }
39
+
40
+ url << string
41
+ url = url[0...-1] if (url[-1] == '&')
42
+ end
43
+
44
+ return url
45
+ end
46
+
47
+ def self.post_url(post_type)
48
+ if post_type == nil
49
+ "#{BASE_URL}?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
50
+ else
51
+ case post_type
52
+ when "message_customer"
53
+ "#{BASE_URL}/api_send_message?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
54
+ when "add_customer" || "update_customer"
55
+ "#{BASE_URL}/api_add_customer?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
56
+ end
57
+ end
58
+ end
47
59
 
48
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_desk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elijah Murray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -104,11 +104,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  requirements: []
106
106
  rubyforge_project:
107
- rubygems_version: 2.0.14
107
+ rubygems_version: 2.1.9
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Provides a clean and simple gem to connect to Simple Desk
111
111
  test_files:
112
112
  - spec/my_spec.rb
113
113
  - spec/spec_helper.rb
114
- has_rdoc: