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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b70d23fdd77697269c4c0d6b1bf33e987ed51c6
4
- data.tar.gz: 75255aa85e2e519deebce54a7412ae9dcd3636ed
3
+ metadata.gz: d55b96c5dfbfdddf6b0820c5007009fb9bc6a78f
4
+ data.tar.gz: 84d1f3dd5cb416637b9bb1d04c50fd4d2941c900
5
5
  SHA512:
6
- metadata.gz: eca9cf67e9733c8c30ecc59f0b4f7a5686016bba3625bdbe23c792339d66904400e6fbde123e8e6eb3e99efb66b8788436766ee7de59ba0fc6baf587fdf4ee45
7
- data.tar.gz: 05496ee1873dfc428b74b0c8eba57b4069e47efc8c736f2294256ca259909980d7ca7c134deff6690960147a28e4dcca2426d83174dbbefb66f16dca585410df
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
- BASE_URL = "https://www.getsimpledesk.com"
6
+ BASE_URL = "https://www.getsimpledesk.com"
7
7
 
8
- def self.add_customer(params, customer_properties = nil)
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 = params.merge(properties: props)
11
+ params.merge(properties: props)
12
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
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
- if params
36
- string = ''
37
- url << "&"
38
- params.each { |k,v| string << "#{k}=#{v}&" }
44
+ url << string
45
+ url = url[0...-1] if (url[-1] == '&')
46
+ end
39
47
 
40
- url << string
41
- url = url[0...-1] if (url[-1] == '&')
42
- end
43
-
44
- return url
45
- end
48
+ return url
49
+ end
46
50
 
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
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
@@ -1,3 +1,3 @@
1
1
  module SimpleDesk
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  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.4
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-08-12 00:00:00.000000000 Z
11
+ date: 2014-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec