changed
CHANGELOG.md
|
@@ -2,6 2,16 @@
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
## 0.2.2 - 2018-10-10
|
6
|
|
7
|
### Fixed
|
8
|
|
9
|
- Fix type specs (#24, #27 by @ jeroenvisser101)
|
10
|
|
11
|
### Added
|
12
|
|
13
|
- Add `describe_global/1` (based on #18 by @mindreframer)
|
14
|
|
5
15
|
## 0.2.1 - 2018-07-30
|
6
16
|
|
7
17
|
### Added
|
|
@@ -31,4 41,4 @@
|
31
41
|
|
32
42
|
- Add basic features
|
33
43
|
|
34
|
- [Unreleased]: https://github.com/chulkilee/ex_force/compare/v0.2.1...HEAD
|
44
|
[Unreleased]: https://github.com/chulkilee/ex_force/compare/v0.2.2...HEAD
|
changed
hex_metadata.config
|
@@ -26,4 26,4 @@
|
26
26
|
{<<"optional">>,false},
|
27
27
|
{<<"repository">>,<<"hexpm">>},
|
28
28
|
{<<"requirement">>,<<"~> 1.0">>}]]}.
|
29
|
- {<<"version">>,<<"0.2.1">>}.
|
29
|
{<<"version">>,<<"0.2.2">>}.
|
changed
lib/ex_force.ex
|
@@ -32,6 32,7 @@ defmodule ExForce do
|
32
32
|
|
33
33
|
import ExForce.Client, only: [request: 2]
|
34
34
|
|
35
|
@type client :: ExForce.Client.t()
|
35
36
|
@type sobject_id :: String.t()
|
36
37
|
@type sobject_name :: String.t()
|
37
38
|
@type field_name :: String.t()
|
|
@@ -60,7 61,7 @@ defmodule ExForce do
|
60
61
|
|
61
62
|
See [Resources by Version](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_discoveryresource.htm)
|
62
63
|
"""
|
63
|
- @spec resources(Client.t(), String.t()) :: {:ok, map} | {:error, any}
|
64
|
@spec resources(client, String.t()) :: {:ok, map} | {:error, any}
|
64
65
|
def resources(client, version) do
|
65
66
|
case request(client, method: :get, url: "/services/data/v#{version}") do
|
66
67
|
{:ok, %Tesla.Env{status: 200, body: body}} -> {:ok, body}
|
|
@@ -96,12 97,26 @@ defmodule ExForce do
|
96
97
|
])
|
97
98
|
end
|
98
99
|
|
100
|
@doc """
|
101
|
Lists the available objects.
|
102
|
|
103
|
See [Describe Global](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_describeGlobal.htm)
|
104
|
"""
|
105
|
@spec describe_global(client) :: {:ok, map} | {:error, any}
|
106
|
def describe_global(client) do
|
107
|
case request(client, method: :get, url: "sobjects") do
|
108
|
{:ok, %Tesla.Env{status: 200, body: body}} -> {:ok, body}
|
109
|
{:ok, %Tesla.Env{body: body}} -> {:error, body}
|
110
|
{:error, _} = other -> other
|
111
|
end
|
112
|
end
|
113
|
|
99
114
|
@doc """
|
100
115
|
Retrieves extended metadata for the specified SObject.
|
101
116
|
|
102
117
|
See [SObject Describe](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_describe.htm)
|
103
118
|
"""
|
104
|
- @spec describe_sobject(Client.t(), sobject_name) :: {:ok, map} | {:error, any}
|
119
|
@spec describe_sobject(client, sobject_name) :: {:ok, map} | {:error, any}
|
105
120
|
def describe_sobject(client, name) do
|
106
121
|
case request(client, method: :get, url: "sobjects/#{name}/describe") do
|
107
122
|
{:ok, %Tesla.Env{status: 200, body: body}} -> {:ok, body}
|
|
@@ -115,7 130,7 @@ defmodule ExForce do
|
115
130
|
|
116
131
|
See [SObject Basic Information](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_basic_info.htm)
|
117
132
|
"""
|
118
|
- @spec basic_info(Client.t(), sobject_name) :: {:ok, map} | {:error, any}
|
133
|
@spec basic_info(client, sobject_name) :: {:ok, map} | {:error, any}
|
119
134
|
def basic_info(client, name) do
|
120
135
|
case request(client, method: :get, url: "sobjects/#{name}") do
|
121
136
|
{:ok, %Tesla.Env{status: 200, body: %{"recentItems" => recent_items} = body}} ->
|
|
@@ -134,8 149,7 @@ defmodule ExForce do
|
134
149
|
|
135
150
|
See [SObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm)
|
136
151
|
"""
|
137
|
- @spec get_sobject(Client.t(), sobject_id, sobject_name, list) ::
|
138
|
- {:ok, SObject.t()} | {:error, any}
|
152
|
@spec get_sobject(client, sobject_id, sobject_name, list) :: {:ok, SObject.t()} | {:error, any}
|
139
153
|
def get_sobject(client, id, name, fields),
|
140
154
|
do: do_get_sobject(client, "sobjects/#{name}/#{id}", fields)
|
141
155
|
|
|
@@ -144,7 158,7 @@ defmodule ExForce do
|
144
158
|
|
145
159
|
See [SObject Rows by External ID](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_upsert.htm)
|
146
160
|
"""
|
147
|
- @spec get_sobject_by_external_id(Client.t(), any, field_name, sobject_name) ::
|
161
|
@spec get_sobject_by_external_id(client, any, field_name, sobject_name) ::
|
148
162
|
{:ok, SObject.t()} | {:error, any}
|
149
163
|
def get_sobject_by_external_id(client, field_value, field_name, sobject_name),
|
150
164
|
do:
|
|
@@ -156,7 170,7 @@ defmodule ExForce do
|
156
170
|
See [SObject Relationships](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_relationships.htm)
|
157
171
|
"""
|
158
172
|
@spec get_sobject_by_relationship(
|
159
|
- Client.t(),
|
173
|
client,
|
160
174
|
sobject_id,
|
161
175
|
sobject_name,
|
162
176
|
field_name,
|
|
@@ -187,7 201,7 @@ defmodule ExForce do
|
187
201
|
|
188
202
|
See [SObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm)
|
189
203
|
"""
|
190
|
- @spec update_sobject(Client.t(), sobject_id, sobject_name, map) :: :ok | {:error, any}
|
204
|
@spec update_sobject(client, sobject_id, sobject_name, map) :: :ok | {:error, any}
|
191
205
|
def update_sobject(client, id, name, attrs) do
|
192
206
|
case request(client, method: :patch, url: "sobjects/#{name}/#{id}", body: attrs) do
|
193
207
|
{:ok, %Tesla.Env{status: 204, body: ""}} -> :ok
|
|
@@ -201,7 215,7 @@ defmodule ExForce do
|
201
215
|
|
202
216
|
See [SObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_basic_info.htm)
|
203
217
|
"""
|
204
|
- @spec create_sobject(Client.t(), sobject_name, map) :: :ok | {:error, any}
|
218
|
@spec create_sobject(client, sobject_name, map) :: {:ok, sobject_id} | {:error, any}
|
205
219
|
def create_sobject(client, name, attrs) do
|
206
220
|
case request(client, method: :post, url: "sobjects/#{name}/", body: attrs) do
|
207
221
|
{:ok, %Tesla.Env{status: 201, body: %{"id" => id, "success" => true}}} -> {:ok, id}
|
|
@@ -215,7 229,7 @@ defmodule ExForce do
|
215
229
|
|
216
230
|
[SObject Rows](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_retrieve.htm)
|
217
231
|
"""
|
218
|
- @spec delete_sobject(Client.t(), sobject_id, sobject_name) :: :ok | {:error, any}
|
232
|
@spec delete_sobject(client, sobject_id, sobject_name) :: :ok | {:error, any}
|
219
233
|
def delete_sobject(client, id, name) do
|
220
234
|
case request(client, method: :delete, url: "sobjects/#{name}/#{id}") do
|
221
235
|
{:ok, %Tesla.Env{status: 204, body: ""}} -> :ok
|
|
@@ -229,7 243,7 @@ defmodule ExForce do
|
229
243
|
|
230
244
|
[Query](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm)
|
231
245
|
"""
|
232
|
- @spec query(Client.t(), soql) :: {:ok, QueryResult.t()} | {:error, any}
|
246
|
@spec query(client, soql) :: {:ok, QueryResult.t()} | {:error, any}
|
233
247
|
def query(client, soql) do
|
234
248
|
case request(client, method: :get, url: "query", query: [q: soql]) do
|
235
249
|
{:ok, %Tesla.Env{status: 200, body: body}} -> {:ok, build_result_set(body)}
|
|
@@ -238,7 252,7 @@ defmodule ExForce do
|
238
252
|
end
|
239
253
|
end
|
240
254
|
|
241
|
- @spec query_stream(Client.t(), soql) :: Enumerable.t()
|
255
|
@spec query_stream(client, soql) :: Enumerable.t()
|
242
256
|
def query_stream(client, soql), do: start_query_stream(client, &query/2, soql)
|
243
257
|
|
244
258
|
@doc """
|
|
@@ -246,8 260,7 @@ defmodule ExForce do
|
246
260
|
|
247
261
|
[Query](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm)
|
248
262
|
"""
|
249
|
- @spec query_retrieve(Client.t(), query_id | String.t()) ::
|
250
|
- {:ok, QueryResult.t()} | {:error, any}
|
263
|
@spec query_retrieve(client, query_id | String.t()) :: {:ok, QueryResult.t()} | {:error, any}
|
251
264
|
def query_retrieve(client, query_id_or_url) do
|
252
265
|
path =
|
253
266
|
if full_path?(query_id_or_url) do
|
|
@@ -268,7 281,7 @@ defmodule ExForce do
|
268
281
|
|
269
282
|
[QueryAll](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_queryall.htm)
|
270
283
|
"""
|
271
|
- @spec query_all(Client.t(), soql) :: {:ok, QueryResult.t()} | {:error, any}
|
284
|
@spec query_all(client, soql) :: {:ok, QueryResult.t()} | {:error, any}
|
272
285
|
def query_all(client, soql) do
|
273
286
|
case request(client, method: :get, url: "queryAll", query: [q: soql]) do
|
274
287
|
{:ok, %Tesla.Env{status: 200, body: body}} -> {:ok, build_result_set(body)}
|
|
@@ -277,7 290,7 @@ defmodule ExForce do
|
277
290
|
end
|
278
291
|
end
|
279
292
|
|
280
|
- @spec query_all_stream(Client.t(), soql) :: Enumerable.t()
|
293
|
@spec query_all_stream(client, soql) :: Enumerable.t()
|
281
294
|
def query_all_stream(client, soql), do: start_query_stream(client, &query_all/2, soql)
|
282
295
|
|
283
296
|
defp build_result_set(%{"records" => records, "totalSize" => total_size} = resp) do
|
|
@@ -300,8 313,8 @@ defmodule ExForce do
|
300
313
|
end
|
301
314
|
|
302
315
|
@spec start_query_stream(
|
303
|
- Client.t(),
|
304
|
- (Client.t(), soql -> {:ok, QueryResult.t()} | any),
|
316
|
client,
|
317
|
(client, soql -> {:ok, QueryResult.t()} | any),
|
305
318
|
soql
|
306
319
|
) :: Enumerable.t()
|
307
320
|
defp start_query_stream(client, func, soql) do
|
|
@@ -312,7 325,7 @@ defmodule ExForce do
|
312
325
|
@doc """
|
313
326
|
Returns `Enumerable.t` from the `QueryResult`.
|
314
327
|
"""
|
315
|
- @spec stream_query_result(Client.t(), QueryResult.t()) :: Enumerable.t()
|
328
|
@spec stream_query_result(client, QueryResult.t()) :: Enumerable.t()
|
316
329
|
def stream_query_result(client, %QueryResult{} = qr) do
|
317
330
|
Stream.unfold({client, qr}, &stream_unfold/1)
|
318
331
|
end
|
changed
lib/ex_force/client.ex
|
@@ -12,4 12,6 @@ defmodule ExForce.Client do
|
12
12
|
"""
|
13
13
|
|
14
14
|
use Tesla
|
15
|
|
16
|
@type t :: Tesla.Client.t()
|
15
17
|
end
|
changed
lib/ex_force/oauth.ex
|
@@ -111,7 111,7 @@ defmodule ExForce.OAuth do
|
111
111
|
```
|
112
112
|
"""
|
113
113
|
|
114
|
- @spec get_token(Client.t() | String.t(), list) ::
|
114
|
@spec get_token(ExForce.Client.t() | String.t(), list) ::
|
115
115
|
{:ok, OAuthResponse.t()} | {:error, :invalid_signature | term}
|
116
116
|
|
117
117
|
def get_token(url, payload) when is_binary(url), do: url |> build_client() |> get_token(payload)
|
changed
mix.exs
|
@@ -1,7 1,7 @@
|
1
1
|
defmodule ExForce.Mixfile do
|
2
2
|
use Mix.Project
|
3
3
|
|
4
|
- @version "0.2.1"
|
4
|
@version "0.2.2"
|
5
5
|
|
6
6
|
def project do
|
7
7
|
[
|