salesforce-lead 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/salesforce/lead.rb +61 -0
- data/lib/salesforce/version.rb +6 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 43c1c4f1aac783dd3335286fa7ca3f697e1382da
|
4
|
+
data.tar.gz: 629ff9670c0734c0ce17c26a83e4ef035bd8486f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f0562f7ae656741ce7869f8c4b9f24bea9677a40b82f3eab89458bc05e7969c787b9aa29012717707fcf9ae2563625f2c4ac6924270ccaa5499dbe2cfc61d5b
|
7
|
+
data.tar.gz: d44841a4bb9a0b375f3ad5ab1da710b89e5d8d8f20c37384d9a7a7fd4f8b2589095274eec1fa62c0f15a0e34e986598f9f2103dc0a35599a654302f01e03c2d2
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Salesforce
|
4
|
+
class Lead
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
headers 'Content-Type' => 'application/json'
|
8
|
+
debug_output $stderr if defined?(Rails) && Rails.env.development?
|
9
|
+
|
10
|
+
attr_accessor :last_name, :email, :company, :job_title, :phone, :website,
|
11
|
+
:credentials, :response, :errors
|
12
|
+
|
13
|
+
CREATE_PATH = 'services/data/v29.0/sobjects/Lead/'.freeze
|
14
|
+
|
15
|
+
def initialize(attributes, credentials)
|
16
|
+
@last_name = attributes[:last_name]
|
17
|
+
@email = attributes[:email]
|
18
|
+
@company = attributes[:company]
|
19
|
+
@job_title = attributes[:job_title]
|
20
|
+
@phone = attributes[:phone]
|
21
|
+
@website = attributes[:website]
|
22
|
+
@credentials = credentials
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@response = self.class.post(create_url, headers: auth_header, body: to_json)
|
27
|
+
success? ? true : parse_errors
|
28
|
+
end
|
29
|
+
|
30
|
+
def success?
|
31
|
+
@response.code >= 200 && @response.code < 400
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse_errors
|
35
|
+
@errors = @response.parsed_response.map do |error|
|
36
|
+
{ message: error['message'], code: error['errorCode'] }
|
37
|
+
end
|
38
|
+
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_url
|
43
|
+
"#{ @credentials[:instance_url] }/#{ CREATE_PATH }"
|
44
|
+
end
|
45
|
+
|
46
|
+
def auth_header
|
47
|
+
{ 'Authorization' => "Bearer #{ @credentials[:token] }" }
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_json
|
51
|
+
{
|
52
|
+
'LastName' => last_name,
|
53
|
+
'Email' => email,
|
54
|
+
'Company' => company,
|
55
|
+
'Title' => job_title,
|
56
|
+
'Phone' => phone,
|
57
|
+
'Website' => website
|
58
|
+
}.to_json
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: salesforce-lead
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leonardo Tegon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubygems-tasks
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.21.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.21.0
|
69
|
+
description: Create a Lead in Salesforce
|
70
|
+
email: ltegon93@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- lib/salesforce/lead.rb
|
76
|
+
- lib/salesforce/version.rb
|
77
|
+
homepage: https://github.com/tegon/salesforce-lead
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Salesforce Lead
|
101
|
+
test_files: []
|