workato-connector-sdk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 69135213fcf4d8deb7f290a45bd54ddf8baf9043
4
- data.tar.gz: d3dbc7fc42c28b77bf1574d9a443da621c85ded6
2
+ SHA256:
3
+ metadata.gz: b81c1b9e954ad72d48fdf3a32fa33cb3de02a3115d00e14868226234c98f32ee
4
+ data.tar.gz: 22b5572360e2dfd03938acc98857fdd9c8e0bb9d097af83aaf871404bb3312ff
5
5
  SHA512:
6
- metadata.gz: e40792dcaf023b036249568a6c0b89b018f1a4b5591413b2676badeb056e5068a86ddaf14a9fb7cae7c3168fd528a679046c288ca35b5a80665ea45bf3309257
7
- data.tar.gz: 9de77780a8a2a7e300a5af38fc91cef3dfdac6fed8846a46d317eb3d4cabba102445202cca6ea63c14eb0418c146c1eba4d07f9929e1fb419e988c9aaa74b7d6
6
+ metadata.gz: d9d2044bf8f7959198c2a5ee791661dd4be30a5474b74dc6c40ea8b359b99e8d1acfd965b44727c27194e5a8efab8f3d50f6703370ef0a4a00868034d1ca80d9
7
+ data.tar.gz: a40cbb8272f22247b29be7b15be2708f1339329e771fd2a994ac9e174ddb67c2bba0e0a0474fe5a68fcd457220d884b0e56f50321b9611f436136202881d17f7
data/README.md CHANGED
@@ -15,6 +15,7 @@ This guide below showcases how you can do the following things:
15
15
  1. Install [RVM ("Ruby Version Manager")](http://rvm.io/) or a Ruby manager of your choice. You can find more at [here](https://www.ruby-lang.org/en/documentation/installation/)
16
16
  2. Choose between Ruby versions `2.4.10` `2.5.X` or `2.7.X`. Our preferred version is `2.7.X`.
17
17
  3. Verify you're running a valid ruby version. Do this by running either `ruby -v` or the commands within your version manager. i.e., `rvm current` if you have installed RVM.
18
+ 4. For Windows you need tzinfo-data gem installed as well. `gem install tzinfo-data`
18
19
 
19
20
  ```bash
20
21
  ruby -v
@@ -38,7 +39,7 @@ Commands:
38
39
  workato generate <SUBCOMMAND> # Generates code from template
39
40
  workato help [COMMAND] # Describe available commands or one specific command
40
41
  workato new <CONNECTOR_PATH> # Inits new connector folder
41
- workato push <FOLDER> # Upload and release connector's code
42
+ workato push # Upload and release connector's code
42
43
 
43
44
  Options:
44
45
  [--verbose], [--no-verbose]
@@ -124,11 +125,11 @@ You don't need to create this file. It'll be created later on. This file just ho
124
125
 
125
126
  ### 2.5 README.MD
126
127
  This file shows up on your Github project (or other Git software you use). Use it to document what your connector does! **Not created via `workato new <PATH>` commands.**
127
- When you use the `workato push <FOLDER>` command to sync your connector with your Workato workspace, this is the default file for your connector's description.
128
+ When you use the `workato push` command to sync your connector with your Workato workspace, this is the default file for your connector's description.
128
129
 
129
130
  ### 2.6 logo.png
130
131
  The logo of your connector. **Not created via `workato new <PATH>` commands.**
131
- When you use the `workato push <FOLDER>` command to sync your connector with your Workato workspace, this is the default file for your connector's logo.
132
+ When you use the `workato push` command to sync your connector with your Workato workspace, this is the default file for your connector's logo.
132
133
 
133
134
  ### 2.7 connector.rb
134
135
  Well, this is your actual connector code. This file should be a replica of your connector code in Workato.
@@ -223,7 +224,7 @@ Commands:
223
224
  workato generate <SUBCOMMAND> # Generates code from template
224
225
  workato help [COMMAND] # Describe available commands or one specific command
225
226
  workato new <CONNECTOR_PATH> # Inits new connector folder
226
- workato push <FOLDER> # Upload and release connector's code
227
+ workato push # Upload and release connector's code
227
228
 
228
229
  Options:
229
230
  [--verbose], [--no-verbose]
@@ -362,7 +363,7 @@ Please select default HTTP mocking behavior suitable for your project?
362
363
  workato help push
363
364
 
364
365
  Usage:
365
- workato push <FOLDER>
366
+ workato push
366
367
 
367
368
  Options:
368
369
  -t, [--title=TITLE] # Connector title on the Workato Platform
@@ -375,7 +376,8 @@ Options:
375
376
  [--environment=ENVIRONMENT] # Server to push connector code to
376
377
  # Default: live
377
378
  # Possible values: preview, preview-eu, live, live-eu
378
- [--verbose], [--no-verbose]
379
+ [--folder=FOLDER] # Folder ID if you what to push to folder other than Home
380
+ [--verbose], [--no-verbose]
379
381
 
380
382
  Upload and release connector's code
381
383
  ```
@@ -1086,8 +1088,7 @@ jobs:
1086
1088
  # env:
1087
1089
  # WORKATO_API_EMAIL: ${{ secrets.WORKATO_DEV_ENVIRONMENT_API_EMAIL}}
1088
1090
  # WORKATO_API_TOKEN: ${{ secrets.WORKATO_DEV_ENVIRONMENT_API_TOKEN}}
1089
- # WORKATO_API_FOLDER: ${{ secrets.WORKATO_DEV_ENVIRONMENT_API_HOME_FOLDER}}
1090
- # run: workato push $WORKATO_API_FOLDER
1091
+ # run: workato push
1091
1092
  ```
1092
1093
 
1093
1094
  You may also add more Github actions for rubocop to automate this.
@@ -30,7 +30,7 @@ module Workato
30
30
  def create_spec_files
31
31
  template('.rspec.erb', '.rspec')
32
32
 
33
- @vcr_record_mode = ask(<<~HELP)
33
+ say(<<~HELP)
34
34
  Please select default HTTP mocking behavior suitable for your project?
35
35
 
36
36
  1 - secure. Cause an error to be raised for any unknown requests, all request recordings are encrypted.
@@ -39,8 +39,11 @@ module Workato
39
39
  Example: VCR_RECORD_MODE=once bundle exec rspec spec/actions/test_action_spec.rb
40
40
 
41
41
  2 - simple. Record new interaction if it is a new request, requests are stored as plain text and expose secret tokens.
42
+
42
43
  HELP
43
44
 
45
+ @vcr_record_mode = ask('Your choice:')
46
+
44
47
  MasterKeyGenerator.new.call if @vcr_record_mode == '1'
45
48
 
46
49
  template('spec/spec_helper.rb.erb', 'spec/spec_helper.rb')
@@ -95,7 +95,7 @@ module Workato
95
95
  desc 'generate <SUBCOMMAND>', 'Generates code from template'
96
96
  subcommand('generate', GenerateCommand)
97
97
 
98
- desc 'push <FOLDER>', "Upload and release connector's code"
98
+ desc 'push', "Upload and release connector's code"
99
99
  method_option :title,
100
100
  type: :string,
101
101
  aliases: '-t',
@@ -130,10 +130,12 @@ module Workato
130
130
  enum: Workato::CLI::PushCommand::ENVIRONMENTS.keys,
131
131
  default: 'live',
132
132
  desc: 'Server to push connector code to'
133
+ method_option :folder,
134
+ type: :string,
135
+ desc: 'Folder ID if you what to push to folder other than Home'
133
136
 
134
- def push(folder)
137
+ def push
135
138
  PushCommand.new(
136
- folder: folder,
137
139
  options: options
138
140
  ).call
139
141
  end
@@ -3,6 +3,7 @@
3
3
  require 'uri'
4
4
  require 'ruby-progressbar'
5
5
  require 'zip'
6
+ require 'fileutils'
6
7
 
7
8
  module Workato
8
9
  module CLI
@@ -19,6 +20,7 @@ module Workato
19
20
  'live-eu' => 'https://app.eu.workato.com'
20
21
  }.freeze
21
22
 
23
+ API_USER_PATH = '/api/users/me'
22
24
  API_IMPORT_PATH = '/api/packages/import'
23
25
  API_PACKAGE_PATH = '/api/packages'
24
26
  IMPORT_IN_PROGRESS = 'in_progress'
@@ -30,19 +32,19 @@ module Workato
30
32
  AWAIT_IMPORT_SLEEP_INTERVAL = 15 # seconds
31
33
  AWAIT_IMPORT_TIMEOUT_INTERVAL = 120 # seconds
32
34
 
33
- def initialize(folder:, options:)
34
- @folder_id = folder
35
+ def initialize(options:)
35
36
  @options = options
36
37
  @api_base_url = ENVIRONMENTS.fetch(options[:environment])
37
38
  @api_email = options[:api_email] || ENV[WORKATO_API_EMAIL_ENV]
38
39
  @api_token = options[:api_token] || ENV[WORKATO_API_TOKEN_ENV]
40
+ @folder_id = options[:folder]
39
41
  end
40
42
 
41
43
  def call
42
- zip_file = build_package
44
+ zip_file_path = build_package
43
45
  say_status :success, 'Build package' if verbose?
44
46
 
45
- import_id = import_package(zip_file)
47
+ import_id = import_package(zip_file_path)
46
48
  say_status :success, 'Upload package' if verbose?
47
49
  say_status :waiting, 'Process package' if verbose?
48
50
 
@@ -55,13 +57,12 @@ module Workato
55
57
  rescue StandardError => e
56
58
  say e.message
57
59
  ensure
58
- zip_file&.close(true)
60
+ FileUtils.rm_f(zip_file_path) if zip_file_path
59
61
  end
60
62
 
61
63
  private
62
64
 
63
65
  attr_reader :options,
64
- :folder_id,
65
66
  :api_token,
66
67
  :api_email,
67
68
  :api_base_url
@@ -78,16 +79,13 @@ module Workato
78
79
  end
79
80
 
80
81
  def build_package
81
- zip_file = Tempfile.new(['connector', '.zip'])
82
-
83
- ::Zip::OutputStream.open(zip_file.path) { |_| 'no-op' }
84
- ::Zip::File.open(zip_file.path, ::Zip::File::CREATE) do |archive|
85
- add_connector(archive)
86
- add_manifest(archive)
87
- add_logo(archive)
82
+ ::Dir::Tmpname.create(['connector', '.zip']) do |path|
83
+ ::Zip::File.open(path, ::Zip::File::CREATE) do |archive|
84
+ add_connector(archive)
85
+ add_manifest(archive)
86
+ add_logo(archive)
87
+ end
88
88
  end
89
-
90
- zip_file
91
89
  end
92
90
 
93
91
  def add_connector(archive)
@@ -110,11 +108,11 @@ module Workato
110
108
  end
111
109
  end
112
110
 
113
- def import_package(zip_file)
111
+ def import_package(zip_file_path)
114
112
  url = "#{api_base_url}#{API_IMPORT_PATH}/#{folder_id}"
115
113
  response = RestClient.post(
116
114
  url,
117
- File.open(zip_file.path),
115
+ File.open(zip_file_path),
118
116
  auth_headers.merge(
119
117
  'Content-Type' => 'application/zip'
120
118
  )
@@ -197,7 +195,21 @@ module Workato
197
195
  }
198
196
  end
199
197
 
198
+ def folder_id
199
+ @folder_id ||=
200
+ begin
201
+ url = "#{api_base_url}#{API_USER_PATH}"
202
+ response = RestClient.get(url, auth_headers)
203
+
204
+ json = JSON.parse(response.body)
205
+ json.fetch('root_folder_id').tap do |folder_id|
206
+ say_status :success, "Fetch root folder ID: #{folder_id}" if verbose?
207
+ end
208
+ end
209
+ end
210
+
200
211
  private_constant :IMPORT_IN_PROGRESS,
212
+ :API_USER_PATH,
201
213
  :API_IMPORT_PATH,
202
214
  :API_PACKAGE_PATH,
203
215
  :PACKAGE_ENTRY_NAME,
@@ -18,4 +18,11 @@ module Workato
18
18
  end
19
19
  end
20
20
 
21
- ::Time.zone = Workato::Connector::Sdk::DEFAULT_TIME_ZONE
21
+ begin
22
+ ::Time.zone = Workato::Connector::Sdk::DEFAULT_TIME_ZONE
23
+ rescue TZInfo::DataSourceNotFound
24
+ puts ''
25
+ puts "tzinfo-data is not present. Please install gem 'tzinfo-data' by 'gem install tzinfo-data'"
26
+ puts ''
27
+ exit!
28
+ end
@@ -3,7 +3,7 @@
3
3
  module Workato
4
4
  module Connector
5
5
  module Sdk
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.2'
7
7
  end
8
8
  end
9
9
  end
@@ -5,6 +5,7 @@ source 'https://rubygems.org'
5
5
  gem 'byebug'
6
6
  gem 'rspec'
7
7
  gem 'timecop'
8
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
8
9
  gem 'vcr'
9
10
  gem 'webmock'
10
11
  gem 'workato-connector-sdk'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workato-connector-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Abolmasov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-16 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -369,8 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
369
369
  - !ruby/object:Gem::Version
370
370
  version: '0'
371
371
  requirements: []
372
- rubyforge_project:
373
- rubygems_version: 2.6.14.4
372
+ rubygems_version: 3.2.3
374
373
  signing_key:
375
374
  specification_version: 4
376
375
  summary: Gem for running adapter's code outside Workato infrastructure