simple_desk 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/simple_desk.rb +37 -33
- data/lib/simple_desk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55b96c5dfbfdddf6b0820c5007009fb9bc6a78f
|
4
|
+
data.tar.gz: 84d1f3dd5cb416637b9bb1d04c50fd4d2941c900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bd834ffbd274617379cabed8bc9d17f15063dac68299fbc2f15f9b51f1d4720de2393d67d1168259c666f87fc8331538beb2cf6008cc700474aa05214f7e52d
|
7
|
+
data.tar.gz: 7a9b3a41b9d5441b2b250377fa26456aa6dfa3990759fcb9e78314a1e3b96180156c3cef159ed25bdd37b535a09bb0293545d1c5f29f28e221b5c9b2d7e9b847
|
data/lib/simple_desk.rb
CHANGED
@@ -3,21 +3,30 @@ require "net/http"
|
|
3
3
|
require "uri"
|
4
4
|
|
5
5
|
module SimpleDesk
|
6
|
-
|
6
|
+
BASE_URL = "https://www.getsimpledesk.com"
|
7
7
|
|
8
|
-
|
8
|
+
def self.add_customer(params, customer_properties)
|
9
9
|
unless customer_properties.blank?
|
10
10
|
props = Base64.urlsafe_encode64(customer_properties.to_json)
|
11
|
-
params
|
11
|
+
params.merge(properties: props)
|
12
12
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
21
30
|
|
22
31
|
def self.message_customer(message_and_phone_number)
|
23
32
|
url = URI.parse(post_url("message_customer"))
|
@@ -32,29 +41,24 @@ module SimpleDesk
|
|
32
41
|
def self.build_url(post_type = nil, params=nil)
|
33
42
|
url = post_url(post_type)
|
34
43
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
params.each { |k,v| string << "#{k}=#{v}&" }
|
44
|
+
url << string
|
45
|
+
url = url[0...-1] if (url[-1] == '&')
|
46
|
+
end
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
return url
|
45
|
-
end
|
48
|
+
return url
|
49
|
+
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
def self.post_url(post_type)
|
52
|
+
if post_type == nil
|
53
|
+
"#{BASE_URL}?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
|
54
|
+
else
|
55
|
+
case post_type
|
56
|
+
when "message_customer"
|
57
|
+
"#{BASE_URL}/api_send_message?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
|
58
|
+
when "add_customer" || "update_customer"
|
59
|
+
"#{BASE_URL}/api_add_customer?token=#{ENV['SIMPLE_DESK_TOKEN'] || CONFIG['simple_desk_token']}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
59
63
|
|
60
64
|
end
|
data/lib/simple_desk/version.rb
CHANGED
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.
|
4
|
+
version: 0.4.0
|
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-
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|