cloudscrape-client 0.2.2 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 182b98c64f47b1616bd3fa10fb66fde547824dad
4
- data.tar.gz: feb1b78bb607e10abc3f3b949b779b4ea12598ad
3
+ metadata.gz: 5085edcfddc61623f67b1082a7ade15bb7f7fc7d
4
+ data.tar.gz: 0f78df125cbfe6430bdb253de187eecd10aa0ceb
5
5
  SHA512:
6
- metadata.gz: 0851c25b22623fb7f9e0f812f9a39e977ced9c92bffd253a602bcefa91aff6f60f530c7ff5ef4a82a449cfea3e723b4f841af755d527630c7d38aa17ea4d115d
7
- data.tar.gz: c38cabc7f07b65f3aa7a4feeb436f3e277e47e3bf25a4302100756e812ba5e68578290c71b086c65a89ec0e71795abea4b9299ceb4555761ce3d341357cc4b48
6
+ metadata.gz: d395feb17c6fc5211dbbb293de993bb1fb46b4d75b0156ddc543780af0f628d858ae137a9f52d94b1cbafacb67141d4439d5a86ea2ac08634558283475d36425
7
+ data.tar.gz: b516059b707b2bc147b40d7197ead42bec76d160590c6ab39823963a5cbb8b744c7b1c2eb15c5ed1db3f207159e68780294e412a61619f5b6e7dc72c94ad0a21
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ /.ruby-version
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /Gemfile.lock
@@ -0,0 +1,27 @@
1
+ ## 0.3.0 (2016-03-23)
2
+
3
+ Features:
4
+
5
+ - wrap executions response in results object to handle collections
6
+
7
+ Deprecations:
8
+
9
+ - deprecate executions `#result` method in favour of `#results`
10
+
11
+ ## Changelog Template
12
+
13
+ Performance:
14
+
15
+ - performance change a
16
+
17
+ Features:
18
+
19
+ - feature a
20
+
21
+ Bugfixes:
22
+
23
+ - bugfix a
24
+
25
+ Deprecations:
26
+
27
+ - deprecation a
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Wrapper for CloudScrape API.
4
4
 
5
- * [API Documentation](https://app.cloudscrape.com/#/api)
6
- * [Support](https://cloudscrape.zendesk.com/hc/en-us)
5
+ * [API Documentation](https://app.dexi.io/#/api)
6
+ * [Support](http://support.dexi.io/)
7
7
 
8
8
  ## Requirements
9
9
 
@@ -27,7 +27,7 @@ Or install it yourself as:
27
27
 
28
28
  ``` ruby
29
29
  CloudscrapeClient.configure do |config|
30
- config.base_url = "https://app.cloudscrape.com/api/"
30
+ config.base_url = "https://api.dexi.io/"
31
31
  config.api_key = "pol6BFzsASYw4gQBl02b24nt"
32
32
  config.account_id = "a814a8r2-a664-4rcb-759c-9de21744117a"
33
33
  config.user_agent_app = "MY-AGENT"
@@ -41,7 +41,7 @@ end
41
41
  Some configuration can be set by environment variables:
42
42
 
43
43
  ``` bash
44
- CLOUD_SCRAPE_CLIENT_BASE_URL="https://app.cloudscrape.com/api/"
44
+ CLOUD_SCRAPE_CLIENT_BASE_URL="https://api.dexi.io/"
45
45
  CLOUD_SCRAPE_CLIENT_API_KEY="pol6BFzsASYw4gQBl02b24nt"
46
46
  CLOUD_SCRAPE_CLIENT_ACCOUNT_ID="a814a8r2-a664-4rcb-759c-9de21744117a"
47
47
  CLOUD_SCRAPE_CLIENT_USER_AGENT_APP="MY-AGENT"
@@ -50,7 +50,7 @@ CLOUD_SCRAPE_CLIENT_TIMEOUT=60000
50
50
  CLOUD_SCRAPE_CLIENT_VERBOSE=true
51
51
  ```
52
52
 
53
- * `base_url` sets the CloudScrape API url `https://app.cloudscrape.com/api/`
53
+ * `base_url` sets the CloudScrape API url `https://api.dexi.io/`
54
54
  * `api_key` sets the CloudScrape API Key `nil`
55
55
  * `user_agent_app` sets the UserAgent app sent to CloudScrape `CS-RUBY-CLIENT`
56
56
  * `user_agent_version` sets the UserAgent version sent to CloudscrapeClient `1.0`
@@ -68,13 +68,13 @@ client = CloudscrapeClient.new(
68
68
  )
69
69
  ```
70
70
 
71
- #### Runs (Execute) [Docs](https://app.cloudscrape.com/#/api/sections/runs/execute)
71
+ #### Runs (Execute) [Docs](https://app.dexi.io/#/api/sections/runs/execute)
72
72
 
73
73
  ``` ruby
74
74
  execution_id = client.runs(run_id).execute
75
75
  ```
76
76
 
77
- #### Runs (Execute with Input) [Docs](https://app.cloudscrape.com/#/api/sections/runs/executeWithInput)
77
+ #### Runs (Execute with Input) [Docs](https://app.dexi.io/#/api/sections/runs/executeWithInput)
78
78
 
79
79
  When `connect: true` is passed execution will upload it's result to configured integrations for this run.
80
80
 
@@ -82,7 +82,7 @@ When `connect: true` is passed execution will upload it's result to configured i
82
82
  execution_id = client.runs(run_id).execute(input: { url: 'http://google.com' }, connect: true)
83
83
  ```
84
84
 
85
- #### Executions (Get) [Docs](https://app.cloudscrape.com/#/api/sections/executions/get)
85
+ #### Executions (Get) [Docs](https://app.dexi.io/#/api/sections/executions/get)
86
86
 
87
87
  ``` ruby
88
88
  execution = client.executions(execution_id).get
@@ -94,29 +94,30 @@ execution.stopped? # => false
94
94
  execution.ok? # => false
95
95
  ```
96
96
 
97
- #### Executions (Remove) [Docs](https://app.cloudscrape.com/#/api/sections/executions/remove)
97
+ #### Executions (Remove) [Docs](https://app.dexi.io/#/api/sections/executions/remove)
98
98
 
99
99
  ``` ruby
100
100
  client.executions(execution_id).remove
101
101
  ```
102
102
 
103
- #### Executions (Get Result) [Docs](https://app.cloudscrape.com/#/api/sections/executions/getResult)
103
+ #### Executions (Get Result) [Docs](https://app.dexi.io/#/api/sections/executions/getResult)
104
104
 
105
105
  Methods are dynamically defined based on headers.
106
106
 
107
107
  ``` ruby
108
- execution = client.executions(execution_id).result
108
+ execution = client.executions(execution_id).results
109
109
  execution.response # => { headers: [...], rows: [...] }
110
- execution.as_hash # => { ... }
110
+ execution.collection # => [ #<CloudscrapeClient::Executions::Result:0x007ffd7d132950> ]
111
+ execution.as_hash # => [ { ... } ]
111
112
  ```
112
113
 
113
- #### Executions (Stop) [Docs](https://app.cloudscrape.com/#/api/sections/executions/stop)
114
+ #### Executions (Stop) [Docs](https://app.dexi.io/#/api/sections/executions/stop)
114
115
 
115
116
  ``` ruby
116
117
  client.executions(execution_id).stop
117
118
  ```
118
119
 
119
- #### Executions (Continue) [Docs](https://app.cloudscrape.com/#/api/sections/executions/continue)
120
+ #### Executions (Continue) [Docs](https://app.dexi.io/#/api/sections/executions/continue)
120
121
 
121
122
  ``` ruby
122
123
  client.executions(execution_id).continue
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.name = "cloudscrape-client"
9
9
  spec.version = CloudscrapeClient::VERSION
10
10
  spec.authors = ["Charles J Hardy"]
11
- spec.email = ["support@cloudscrape.com"]
11
+ spec.email = ["support@dexi.io"]
12
12
 
13
13
  spec.summary = "Wrapper for CloudScrape API"
14
14
  spec.description = "Wrapper for CloudScrape API"
@@ -37,8 +37,7 @@ class CloudscrapeClient
37
37
  private
38
38
 
39
39
  def base_url_default
40
- ENV["CLOUD_SCRAPE_CLIENT_BASE_URL"] ||
41
- "https://app.cloudscrape.com/api/"
40
+ ENV["CLOUD_SCRAPE_CLIENT_BASE_URL"] || "https://api.dexi.io/"
42
41
  end
43
42
 
44
43
  def user_agent_app_default
@@ -1,6 +1,7 @@
1
1
  require "cloudscrape_client/execution_dto"
2
2
  require "cloudscrape_client/executions/get"
3
3
  require "cloudscrape_client/executions/result"
4
+ require "cloudscrape_client/executions/results"
4
5
 
5
6
  class CloudscrapeClient
6
7
  class Executions
@@ -13,7 +14,12 @@ class CloudscrapeClient
13
14
  end
14
15
 
15
16
  def result
16
- Result.new(response: dto("result", :get))
17
+ warn "[DEPRECATION] `result` is deprecated. Please use `results` instead."
18
+ results.collection.first
19
+ end
20
+
21
+ def results
22
+ @results ||= Results.new(response: dto("result", :get))
17
23
  end
18
24
 
19
25
  def remove
@@ -1,10 +1,11 @@
1
1
  class CloudscrapeClient
2
2
  class Executions
3
3
  class Result
4
- attr_reader :response
4
+ attr_reader :row
5
5
 
6
- def initialize(response:)
7
- @response = response
6
+ def initialize(headers:, row:)
7
+ @headers = headers
8
+ @row = row
8
9
  build
9
10
  end
10
11
 
@@ -13,19 +14,11 @@ class CloudscrapeClient
13
14
  end
14
15
 
15
16
  def as_hash
16
- @as_hash ||= Hash[headers.zip(rows)]
17
+ @as_hash ||= Hash[@headers.zip(row)]
17
18
  end
18
19
 
19
20
  private
20
21
 
21
- def headers
22
- response.fetch(:headers, [])
23
- end
24
-
25
- def rows
26
- response.fetch(:rows, [[]]).first
27
- end
28
-
29
22
  def define_method_for_header
30
23
  ->(key, value) { self.class.send(:define_method, key) { value } }
31
24
  end
@@ -0,0 +1,31 @@
1
+ class CloudscrapeClient
2
+ class Executions
3
+ class Results
4
+ attr_reader :response
5
+
6
+ def initialize(response:)
7
+ @response = response
8
+ end
9
+
10
+ def as_hash
11
+ collection.map(&:as_hash)
12
+ end
13
+
14
+ def collection
15
+ response.fetch(:rows, [[]]).map(&result)
16
+ end
17
+
18
+ private
19
+
20
+ def headers
21
+ response.fetch(:headers, [])
22
+ end
23
+
24
+ def result
25
+ lambda do |row|
26
+ CloudscrapeClient::Executions::Result.new(headers: headers, row: row)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  class CloudscrapeClient
2
- VERSION = "0.2.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -37,7 +37,7 @@
37
37
  {
38
38
  "id": "35175ab6-cccf-b3e6-692c-6a66b8c3d30f",
39
39
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
40
- "url": "https://app.cloudscrape.com/api/executions/1f164370-704b-4402-bc15-ba1d00a19d01",
40
+ "url": "https://api.dexi.io/executions/1f164370-704b-4402-bc15-ba1d00a19d01",
41
41
  "preRequestScript": "",
42
42
  "pathVariables": {},
43
43
  "method": "GET",
@@ -49,7 +49,7 @@
49
49
  "helperAttributes": {},
50
50
  "time": 1444436953179,
51
51
  "name": "Get",
52
- "description": "Get execution\n\nhttps://app.cloudscrape.com/#/api/sections/executions/get",
52
+ "description": "Get execution\n\nhttps://app.dexi.io/#/api/sections/executions/get",
53
53
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
54
54
  "responses": [],
55
55
  "folder": "71488e93-9454-db51-8b9c-e15eb0ccfda8"
@@ -57,7 +57,7 @@
57
57
  {
58
58
  "id": "744fd5a4-c477-2fe8-3bbd-66646767b46d",
59
59
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
60
- "url": "https://app.cloudscrape.com/api/executions/1f164370-704b-4402-bc15-ba1d00a19d01/stop",
60
+ "url": "https://api.dexi.io/executions/1f164370-704b-4402-bc15-ba1d00a19d01/stop",
61
61
  "preRequestScript": "",
62
62
  "pathVariables": {},
63
63
  "method": "POST",
@@ -69,7 +69,7 @@
69
69
  "helperAttributes": {},
70
70
  "time": 1444436980442,
71
71
  "name": "Stop",
72
- "description": "Stop execution. Note that an execution does not stop immediately.\n\nhttps://app.cloudscrape.com/#/api/sections/executions/stop",
72
+ "description": "Stop execution. Note that an execution does not stop immediately.\n\nhttps://app.dexi.io/#/api/sections/executions/stop",
73
73
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
74
74
  "responses": [],
75
75
  "folder": "71488e93-9454-db51-8b9c-e15eb0ccfda8"
@@ -77,7 +77,7 @@
77
77
  {
78
78
  "id": "96ea0c3f-a697-e240-e554-c056680beba4",
79
79
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
80
- "url": "https://app.cloudscrape.com/api/executions/1f164370-704b-4402-bc15-ba1d00a19d01/continue",
80
+ "url": "https://api.dexi.io/executions/1f164370-704b-4402-bc15-ba1d00a19d01/continue",
81
81
  "preRequestScript": "",
82
82
  "pathVariables": {},
83
83
  "method": "POST",
@@ -89,7 +89,7 @@
89
89
  "helperAttributes": {},
90
90
  "time": 1444436996122,
91
91
  "name": "Continue",
92
- "description": "Continue a stopped execution. Note that the execution might not start immediately.\n\nhttps://app.cloudscrape.com/#/api/sections/executions/continue",
92
+ "description": "Continue a stopped execution. Note that the execution might not start immediately.\n\nhttps://app.dexi.io/#/api/sections/executions/continue",
93
93
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
94
94
  "responses": [],
95
95
  "folder": "71488e93-9454-db51-8b9c-e15eb0ccfda8"
@@ -97,7 +97,7 @@
97
97
  {
98
98
  "id": "c8d593d5-fac6-0dbf-6710-aca83c8aeecc",
99
99
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
100
- "url": "https://app.cloudscrape.com/api/executions/1f164370-704b-4402-bc15-ba1d00a19d01",
100
+ "url": "https://api.dexi.io/executions/1f164370-704b-4402-bc15-ba1d00a19d01",
101
101
  "preRequestScript": "",
102
102
  "pathVariables": {},
103
103
  "method": "DELETE",
@@ -109,7 +109,7 @@
109
109
  "helperAttributes": {},
110
110
  "time": 1444437024303,
111
111
  "name": "Remove",
112
- "description": "Delete execution permanently\n\nhttps://app.cloudscrape.com/#/api/sections/executions/remove",
112
+ "description": "Delete execution permanently\n\nhttps://app.dexi.io/#/api/sections/executions/remove",
113
113
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
114
114
  "responses": [],
115
115
  "folder": "71488e93-9454-db51-8b9c-e15eb0ccfda8"
@@ -117,7 +117,7 @@
117
117
  {
118
118
  "id": "d3ecd8c7-c9cf-8c95-5d8b-5a671bfe9403",
119
119
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
120
- "url": "https://app.cloudscrape.com/api/runs/27c719bb-f28f-49f5-aedf-dba2f8e60ba3/execute/inputs?connect=true",
120
+ "url": "https://api.dexi.io/runs/27c719bb-f28f-49f5-aedf-dba2f8e60ba3/execute/inputs?connect=true",
121
121
  "preRequestScript": "",
122
122
  "pathVariables": {},
123
123
  "method": "POST",
@@ -129,7 +129,7 @@
129
129
  "helperAttributes": {},
130
130
  "time": 1444566409009,
131
131
  "name": "Execute with Input",
132
- "description": "Starts new execution of run using the input from the body instead of the run itself.\n\nhttps://app.cloudscrape.com/#/api/sections/runs/executeWithInput",
132
+ "description": "Starts new execution of run using the input from the body instead of the run itself.\n\nhttps://app.dexi.io/#/api/sections/runs/executeWithInput",
133
133
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
134
134
  "responses": [],
135
135
  "rawModeData": "{\n \"url\": \"http://google.com\"\n}"
@@ -137,7 +137,7 @@
137
137
  {
138
138
  "id": "e505df88-7b71-2e0d-798c-8ed3321aca77",
139
139
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
140
- "url": "https://app.cloudscrape.com/api/runs/27c719bb-f28f-49f5-aedf-dba2f8e60ba3/execute",
140
+ "url": "https://api.dexi.io/runs/27c719bb-f28f-49f5-aedf-dba2f8e60ba3/execute",
141
141
  "pathVariables": {},
142
142
  "preRequestScript": "",
143
143
  "method": "POST",
@@ -145,7 +145,7 @@
145
145
  "data": [],
146
146
  "dataMode": "params",
147
147
  "name": "Execute",
148
- "description": "Start new execution of run.\n\nhttps://app.cloudscrape.com/#/api/sections/runs/execute",
148
+ "description": "Start new execution of run.\n\nhttps://app.dexi.io/#/api/sections/runs/execute",
149
149
  "descriptionFormat": "html",
150
150
  "time": 1444433278119,
151
151
  "version": 2,
@@ -159,7 +159,7 @@
159
159
  {
160
160
  "id": "fd463224-a926-201f-75db-8ef02b8c257b",
161
161
  "headers": "X-CloudScrape-Access: d7818ef991012e3c94e8ea3cda149936\nX-CloudScrape-Account: a274a8b2-a664-4acb-959c-9de28644877d\nAccept: application/json\nContent-Type: application/json\nUser-Agent: CS-RUBY-CLIENT/1.0\nAccept-Encoding: UTF-8\nTransfer-Encoding: UTF-8\n",
162
- "url": "https://app.cloudscrape.com/api/executions/1f164370-704b-4402-bc15-ba1d00a19d01/result",
162
+ "url": "https://api.dexi.io/executions/1f164370-704b-4402-bc15-ba1d00a19d01/result",
163
163
  "preRequestScript": "",
164
164
  "pathVariables": {},
165
165
  "method": "GET",
@@ -171,10 +171,10 @@
171
171
  "helperAttributes": {},
172
172
  "time": 1444436918679,
173
173
  "name": "Result",
174
- "description": "Get execution result. As a result can be very large it is advised that you use some method of streaming to parse the result and insert it into your data store of choice.\n\nhttps://app.cloudscrape.com/#/api/sections/executions/getResult",
174
+ "description": "Get execution result. As a result can be very large it is advised that you use some method of streaming to parse the result and insert it into your data store of choice.\n\nhttps://app.dexi.io/#/api/sections/executions/getResult",
175
175
  "collectionId": "929def16-e7c9-d024-873c-bd0b61ee5c46",
176
176
  "responses": [],
177
177
  "folder": "71488e93-9454-db51-8b9c-e15eb0ccfda8"
178
178
  }
179
179
  ]
180
- }
180
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudscrape-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles J Hardy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -166,7 +166,7 @@ dependencies:
166
166
  version: '0'
167
167
  description: Wrapper for CloudScrape API
168
168
  email:
169
- - support@cloudscrape.com
169
+ - support@dexi.io
170
170
  executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
@@ -176,6 +176,7 @@ files:
176
176
  - .rubocop.yml
177
177
  - .simplecov
178
178
  - .travis.yml
179
+ - CHANGELOG.md
179
180
  - CODE_OF_CONDUCT.md
180
181
  - Gemfile
181
182
  - LICENSE.txt
@@ -203,6 +204,7 @@ files:
203
204
  - lib/cloudscrape_client/executions.rb
204
205
  - lib/cloudscrape_client/executions/get.rb
205
206
  - lib/cloudscrape_client/executions/result.rb
207
+ - lib/cloudscrape_client/executions/results.rb
206
208
  - lib/cloudscrape_client/run_dto.rb
207
209
  - lib/cloudscrape_client/runs.rb
208
210
  - lib/cloudscrape_client/validate.rb