salesforceapi-rest 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ require 'active_resource'
7
7
  require 'httparty'
8
8
  require 'builder'
9
9
  require 'crack/xml'
10
+ require 'cgi'
10
11
 
11
12
  module Salesforceapi
12
13
  module Rest
@@ -91,7 +92,7 @@ module Salesforceapi
91
92
  end
92
93
 
93
94
  def config_authorization!
94
- target = target = "https://login.salesforce.com/services/oauth2/token?grant_type=refresh_token&client_id=#{@client_id}&client_secret=#{@client_secret}&refresh_token=#{@refresh_token}"
95
+ target = CGI::unescape("https://login.salesforce.com/services/oauth2/token?grant_type=refresh_token&client_id=#{@client_id}&client_secret=#{@client_secret}&refresh_token=#{@refresh_token}")
95
96
  resp = SalesforceApi::Request.do_request("POST", target, {"content-Type" => 'application/json'}, nil)
96
97
  if (resp.code != 200) || !resp.success?
97
98
  message = ActiveSupport::JSON.decode(resp.body)["error_description"]
@@ -108,7 +109,7 @@ module Salesforceapi
108
109
  end
109
110
 
110
111
 
111
- def add_custom_field(attributes, update = false)
112
+ def add_custom_field(attributes)
112
113
  config_authorization!
113
114
  auth_header = {
114
115
  "Authorization" => "OAuth " + @access_token,
@@ -120,11 +121,7 @@ module Salesforceapi
120
121
  self.class.base_uri @metadata_uri
121
122
 
122
123
  data = (Envelope % [@access_token, custom_fields_xml(attributes)])
123
- if update
124
- resp = SalesforceApi::Request.do_request("POST", @metadata_uri, auth_header, data.lstrip)
125
- else
126
- resp = SalesforceApi::Request.do_request("PUT", @metadata_uri, auth_header, data.lstrip)
127
- end
124
+ resp = SalesforceApi::Request.do_request("POST", @metadata_uri, auth_header, data.lstrip)
128
125
  xml_response = Crack::XML.parse(resp.body)
129
126
 
130
127
  if resp.code != 200
@@ -1,15 +1,16 @@
1
1
  require 'httparty'
2
+ require 'cgi'
2
3
 
3
4
  module SalesforceApi
4
5
  module Request
5
6
  def self.do_request (verb, target, headers, data=nil)
6
7
  case verb
7
8
  when 'GET'
8
- return resp = HTTParty.get(target, :headers => headers)
9
+ return resp = HTTParty.get(CGI::unescape(target), :headers => headers)
9
10
  when 'POST'
10
- return resp = HTTParty.post(target, :body => data, :headers => headers)
11
+ return resp = HTTParty.post(CGI::unescape(target), :body => data, :headers => headers)
11
12
  when 'DELETE'
12
- return resp = HTTParty.delete(target, :headers => headers)
13
+ return resp = HTTParty.delete(CGI::unescape(target), :headers => headers)
13
14
  end
14
15
  end
15
16
  end
@@ -1,5 +1,5 @@
1
1
  module Salesforceapi
2
2
  module Rest
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,166 +1,161 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: salesforceapi-rest
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Lucas Allan Amorim
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-07-23 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rforce
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rforce
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: omniauth
50
39
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
52
41
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: omniauth
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
60
54
  type: :development
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: httparty
64
55
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
66
57
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: httparty
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
74
70
  type: :development
75
- version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: activeresource
78
71
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
80
73
  none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: activeresource
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
88
86
  type: :development
89
- version_requirements: *id005
90
- - !ruby/object:Gem::Dependency
91
- name: crack
92
87
  prerelease: false
93
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: crack
96
+ requirement: !ruby/object:Gem::Requirement
94
97
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
102
  type: :development
103
- version_requirements: *id006
104
- - !ruby/object:Gem::Dependency
105
- name: builder
106
103
  prerelease: false
107
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: builder
112
+ requirement: !ruby/object:Gem::Requirement
108
113
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
116
118
  type: :development
117
- version_requirements: *id007
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
118
126
  description: Ruby wrapper to access salesforce rest api
119
- email:
127
+ email:
120
128
  - lucas.allan@gmail.com
121
129
  executables: []
122
-
123
130
  extensions: []
124
-
125
131
  extra_rdoc_files: []
126
-
127
- files:
132
+ files:
128
133
  - lib/salesforceapi-rest/errors.rb
129
134
  - lib/salesforceapi-rest/request.rb
130
135
  - lib/salesforceapi-rest/version.rb
131
136
  - lib/salesforceapi-rest.rb
132
- homepage: ""
137
+ homepage: ''
133
138
  licenses: []
134
-
135
139
  post_install_message:
136
140
  rdoc_options: []
137
-
138
- require_paths:
141
+ require_paths:
139
142
  - lib
140
- required_ruby_version: !ruby/object:Gem::Requirement
143
+ required_ruby_version: !ruby/object:Gem::Requirement
141
144
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- hash: 3
146
- segments:
147
- - 0
148
- version: "0"
149
- required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- hash: 3
155
- segments:
156
- - 0
157
- version: "0"
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
158
155
  requirements: []
159
-
160
156
  rubyforge_project:
161
157
  rubygems_version: 1.8.24
162
158
  signing_key:
163
159
  specification_version: 3
164
160
  summary: Ruby wrapper to access salesforce rest api
165
161
  test_files: []
166
-