autopilothq 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/autopilothq.rb +45 -0
  3. metadata +72 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8dcad78844f505e7e3e4f232b753ccde1f58488
4
+ data.tar.gz: 60defc4db2fd4c7656cbdc51597eecba4903760c
5
+ SHA512:
6
+ metadata.gz: 720c523410cbb55c63086b31316a91b81fc9d150e0a06a4d144b9c06f75d576396c5428c765abf1db1273d7aeb8494b6040ea33e16b4244c6d7d4ee19c6ee4dd
7
+ data.tar.gz: 86f17874f0bf979ce97aac9ddac9d1fb008daee8a895e63f38ab7ebba9845a931fd309f784a481f7ac1545fd1b3d33e62fa22dd94287a3f65d13031969ba3106
@@ -0,0 +1,45 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+
4
+ class Autopilothq
5
+
6
+ def self.api_key=(key)
7
+ @@api_key = key
8
+ end
9
+
10
+ def self.update_contact(email, custom_attrs)
11
+ attributes = {
12
+ "contact" => {
13
+ "Email" => email,
14
+ "FirstName" => "Bill",
15
+ "LastName" => "ksjdfn",
16
+ "custom" => {}
17
+ }
18
+ }
19
+ custom_attrs.each_pair{ |key, value|
20
+ attributes['contact']['custom'][get_key_name(key, value)] = value
21
+ }
22
+
23
+ response = RestClient.post 'https://api2.autopilothq.com/v1/contact', attributes.to_json, headers
24
+
25
+ return true
26
+ rescue RestClient::RequestFailed => e
27
+ return false
28
+ end
29
+
30
+ def self.headers
31
+ return {
32
+ :autopilotapikey => @@api_key,
33
+ }
34
+ end
35
+
36
+ def self.get_key_name(name, value)
37
+ type = {"Float" => "float",
38
+ "Fixnum" => "integer",
39
+ "String" => "string",
40
+ "TrueClass" => "boolean",
41
+ "FalseClass" => "boolean",
42
+ "Date" => "date"}
43
+ return "#{type[value.class.to_s]}--#{name.gsub(/\s+/, "--")}"
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autopilothq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Culbertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: autopilothq.com api client
42
+ email: justin@repairtechsolutions.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/autopilothq.rb
48
+ homepage:
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.4.3
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: autopilothq.com api client
72
+ test_files: []