strongmind-agilix-buzz-client 0.8.3

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.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/agilix.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "agilix/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "strongmind-agilix-buzz-client"
7
+ spec.version = Agilix::VERSION
8
+ spec.authors = ["Strongmind"]
9
+ spec.email = ["qwertytalk@strongmind.com"]
10
+
11
+ spec.summary = %q{Agilix Buzz API wrapper}
12
+ spec.description = %q{Fully implements Agilix Buzz API in Ruby}
13
+ spec.homepage = "https://github.com/Strongmind/agilix-buzz-client"
14
+
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/Strongmind/agilix-buzz-client"
19
+ spec.metadata["changelog_uri"] = "https://github.com/Strongmind/agilix-buzz-client"
20
+
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler"
32
+ spec.add_development_dependency "rake"
33
+ spec.add_development_dependency "minitest"
34
+ spec.add_development_dependency "vcr"
35
+ spec.add_development_dependency "pry"
36
+ spec.add_development_dependency "dotenv"
37
+ spec.add_dependency "httparty"
38
+ spec.add_dependency "builder"
39
+ spec.add_dependency "webmock"
40
+ end
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ require "dotenv"
3
+ Dotenv.load
4
+ require "bundler/setup"
5
+ require "agilix"
6
+
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ require "pry"
13
+ Pry.start
14
+
15
+ # require "irb"
16
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,175 @@
1
+ module Agilix
2
+ module Buzz
3
+ class Api
4
+ include HTTParty
5
+
6
+ include Agilix::Buzz::Commands::Authentication
7
+ include Agilix::Buzz::Commands::Course
8
+ include Agilix::Buzz::Commands::Domain
9
+ include Agilix::Buzz::Commands::Enrollment
10
+ include Agilix::Buzz::Commands::General
11
+ include Agilix::Buzz::Commands::Library
12
+ include Agilix::Buzz::Commands::Report
13
+ include Agilix::Buzz::Commands::Resource
14
+ include Agilix::Buzz::Commands::Right
15
+ include Agilix::Buzz::Commands::User
16
+
17
+ attr_accessor :username, :password, :domain, :token, :token_expiration, :agilix_url_endpoint
18
+
19
+ def initialize(options = {})
20
+ @username = options.fetch(:username, default_username)
21
+ @password = options.fetch(:password, default_password)
22
+ @domain = options.fetch(:domain, default_domain)
23
+ @token = options.dig(:token)
24
+ @token_expiration = options.dig(:token_expiration)
25
+ @agilix_url_endpoint = options.fetch(:agilix_url_endpoint, default_agilix_url_endpoint)
26
+ end
27
+
28
+ def authenticated_get(query = {})
29
+ check_authentication
30
+ get query
31
+ end
32
+
33
+ def authenticated_post(query = {})
34
+ check_authentication unless query.delete(:bypass_authentication_check)
35
+ post query
36
+ end
37
+
38
+ def authenticated_query_post(query = {})
39
+ check_authentication unless query.delete(:bypass_authentication_check)
40
+ query_post query
41
+ end
42
+
43
+ def authenticated_bulk_post(query = {})
44
+ check_authentication
45
+ bulk_post query
46
+ end
47
+
48
+ def get(query = {})
49
+ response = self.class.get(agilix_url_base, query: modify_query(query), timeout: 60, headers: headers)
50
+ end
51
+
52
+ def post(query = {})
53
+ response = self.class.post(agilix_url_base, body: modify_body(query), timeout: 60, headers: headers)
54
+ end
55
+
56
+ # Not sure if I want to use this yet
57
+ # api.response_parser response: response, path_to_parse: ['response', 'users', 'user'], collection_name: 'users'
58
+ # def response_parser(path_to_parse: nil, collection_name: nil, response: )
59
+ # if path_to_parse
60
+ # result = response.dig(*path_to_parse)
61
+ # ostruct = JSON::parse({collection_name => result}.to_json, object_class: OpenStruct)
62
+ # ostruct.result_count = result.size
63
+ # ostruct.collection_name = collection_name
64
+ # else
65
+ # ostruct = JSON::parse(response.body, object_class: OpenStruct)
66
+ # end
67
+ # ostruct.code = response['code']
68
+ # ostruct.response = response
69
+ # ostruct.request = request
70
+ # ostruct
71
+ # end
72
+
73
+ # For when the api is super unconventional & you need to modify both query params & body params in a custom fashion, and upload a file even!
74
+ def query_post(query = {})
75
+ url = agilix_url_base
76
+ query_params = query.delete(:query_params)
77
+ if query_params
78
+ url += "?&_token=#{token}" + query_params.map {|k,v| "&#{k}=#{v}" }.join("")
79
+ end
80
+ file = query.delete(:file)
81
+ if file
82
+ new_headers = headers
83
+ new_headers["Content-Type"] = "multipart/form-data"
84
+ response = self.class.post(url, multipart: true, body: {file: file}, timeout: 60, headers: new_headers)
85
+ else
86
+ response = self.class.post(url, body: query.to_json, timeout: 60, headers: headers)
87
+ end
88
+ end
89
+
90
+ def bulk_post(query = {})
91
+ cmd = query.delete(:cmd)
92
+ url = agilix_url_base + "?cmd=#{cmd}&_token=#{token}"
93
+ query_params = query.delete(:query_params)
94
+ if query_params
95
+ url += query_params.map {|k,v| "&#{k}=#{v}" }.join("")
96
+ end
97
+ response = self.class.post(url, body: modify_bulk_body(query), timeout: 60, headers: headers)
98
+ end
99
+
100
+ def check_authentication
101
+ if token && token_expiration
102
+ if token_expiration < Time.now
103
+ extend_session
104
+ end
105
+ else
106
+ authenticate!
107
+ end
108
+ end
109
+
110
+ private
111
+
112
+ def authenticate!
113
+ response = login username: @username, password: @password, domain: @domain
114
+ raise AuthenticationError.new(response.dig("response", "message")) if response.dig("response", "code") == "InvalidCredentials"
115
+ @token = response.dig("response", "user", "token")
116
+ @token_expiration = Time.now + (response.dig("response", "user", "authenticationexpirationminutes").to_i * 60 ) if @token
117
+ response
118
+ end
119
+
120
+ def argument_cleaner(required_params: , optional_params: , options: )
121
+ missing_required = required_params - options.map {|k,v| k.to_sym }
122
+ raise ArgumentError.new("Missing Required Arguments: #{missing_required.join(', ')}") if missing_required.any?
123
+ all_params = (required_params + optional_params).flatten
124
+ return options.select {|k,v| all_params.include?(k.to_sym)}
125
+ end
126
+
127
+ def modify_query(query = {})
128
+ default_params = {}
129
+ default_params.merge! query
130
+ default_params["_token"] = token if token
131
+ default_params
132
+ end
133
+
134
+ def modify_body(body = {})
135
+ default_params = { request: {}.merge(body) }
136
+ default_params[:request]["_token"] = token if token
137
+ default_params.to_json
138
+ end
139
+
140
+ def modify_bulk_body(query = {})
141
+ root_node = query.delete(:root_node)
142
+ default_params = { requests: { root_node.to_sym => query[:body] } }
143
+ default_params.to_json
144
+ end
145
+
146
+ def headers
147
+ @headers = {
148
+ "Accept" => "application/json",
149
+ "Content-Type" => "application/json",
150
+ }
151
+ end
152
+
153
+ def default_username
154
+ ENV["AGILIX_BUZZ_USERNAME"]
155
+ end
156
+
157
+ def default_password
158
+ ENV["AGILIX_BUZZ_PASSWORD"]
159
+ end
160
+
161
+ def default_domain
162
+ ENV["AGILIX_BUZZ_DEFAULT_DOMAIN"]
163
+ end
164
+
165
+ def default_agilix_url_endpoint
166
+ ENV.fetch("AGILIX_BUZZ_URL", "https://api.agilixbuzz.com")
167
+ end
168
+
169
+ def agilix_url_base
170
+ @agilix_url_base ||= "#{agilix_url_endpoint}/cmd"
171
+ end
172
+
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,153 @@
1
+ module Agilix
2
+ module Buzz
3
+ module Commands
4
+ module Authentication
5
+
6
+ # This is handled automatically by instantiation of a base Agilix::Buzz::Api instance. It wouldn't need to be called manually unless using for other users or making calls on their behalf
7
+ # api.login username: 'my-username', password: 'my-password', domain: 'my-domain'
8
+ def login2(username: , password: , domain: )
9
+ post cmd: "login2", username: "#{domain}/#{username}", password: password
10
+ end
11
+ alias_method :login, :login2
12
+
13
+ # api.logout
14
+ def logout
15
+ response = authenticated_get cmd: "logout"
16
+ @token = nil
17
+ @token_expiration = nil
18
+ response
19
+ end
20
+
21
+ # This is handled automatically by instantiation of a base Agilix::Buzz::Api instance and on subsequent calls to the api through the check_authentication method
22
+ # api.extend_session
23
+ def extend_session
24
+ response = authenticated_post cmd: "extendsession", bypass_authentication_check: true
25
+ @token_expiration = set_token_expiration(response.dig("response", "session", "authenticationexpirationminutes"))
26
+ authenticate! if response.dig("response", "code") == "NoAuthentication"
27
+ response
28
+ end
29
+
30
+ # api.force_password_change userid: 57181
31
+ def force_password_change(options = {})
32
+ options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
33
+ authenticated_post cmd: "forcepasswordchange", **options
34
+ end
35
+
36
+ # api.get_password_login_attempt_history userid: 57181
37
+ # api.get_password_login_attempt_history userid: 57181, earliestrecordtoreturn: '2018-01-01'
38
+ def get_password_login_attempt_history(options = {})
39
+ options = argument_cleaner(required_params: %i( userid ), optional_params: %i( earliestrecordtoreturn ), options: options )
40
+ authenticated_get cmd: "getpasswordloginattempthistory", **options
41
+ end
42
+
43
+ # api.get_password_policy
44
+ # api.get_password_policy domainid: 57031
45
+ def get_password_policy(options = {})
46
+ options = argument_cleaner(required_params: %i( ), optional_params: %i( domainid bypasscache ), options: options )
47
+ authenticated_get cmd: "getpasswordpolicy", **options
48
+ end
49
+
50
+ # api.get_password_question username: "auto-tests/BuzzUserUp1"
51
+ def get_password_question(options = {})
52
+ options = argument_cleaner(required_params: %i( username ), optional_params: %i( ), options: options )
53
+ authenticated_get cmd: "getpasswordquestion", **options
54
+ end
55
+
56
+ # ISSUE: This works with a GET call
57
+ # api.update_password_question_answer userid: 57181, passwordquestion: "Where is your favorite vacation place?", passwordanswer: "Hawaii"
58
+ def update_password_question_answer(options = {})
59
+ options = argument_cleaner(required_params: %i( userid passwordquestion passwordanswer ), optional_params: %i( oldpassword ), options: options )
60
+ authenticated_post cmd: "updatepasswordquestionanswer", **options
61
+ end
62
+
63
+ # api.proxy userid: 57181
64
+ def proxy(options = {})
65
+ options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
66
+ options[:noazt] ||= true
67
+ authenticated_post cmd: "proxy", **options
68
+ end
69
+
70
+ # proxy_api = api.proxy_api userid: 57181
71
+ # proxy_api.unproxy userid: 57181
72
+ def unproxy(options = {})
73
+ options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
74
+ authenticated_post cmd: "unproxy", **options
75
+ end
76
+
77
+
78
+ # proxy_api = api.proxy_api userid: 57181
79
+ def proxy_api(userid: )
80
+ response = proxy userid: userid
81
+ self.class.new username: response.dig('response', 'user', 'username'), token: response.dig('response', 'user', 'token'), domain: response.dig('response', 'user', 'userspace'), token_expiration: set_token_expiration(response.dig('response', 'user', 'authenticationexpirationminutes'))
82
+ end
83
+
84
+ # api.proxy_sso_link userid: 57181
85
+ def proxy_sso_link(userid: , redirect_url: "home")
86
+ response = proxy userid: userid
87
+ # sso = {
88
+ # "customization": {
89
+ # "authentication": {
90
+ # "provider": {
91
+ # "server": "https://www.google.com"
92
+ # }
93
+ # }
94
+ # }
95
+ # }
96
+ # self.update_domains [ {domainid: response.dig('response', 'user', 'domainid'), data: sso}]
97
+ userspace = response.dig('response', 'user', 'userspace')
98
+ token = response.dig('response', 'user', 'token')
99
+ # "https://api.leaderinme.net/SSOLogin?domainid=#{response.dig('response', 'user', 'domainid')}&url=/home&token=#{response.dig('response', 'user', 'token')}"
100
+ if token && userspace
101
+ "https://#{userspace}.leaderinme.net/login?token=#{token}&url=/#{redirect_url}"
102
+ end
103
+ end
104
+
105
+ # api.reset_lockout userid: 57181
106
+ def reset_lockout(options = {})
107
+ options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
108
+ authenticated_post cmd: "resetlockout", **options
109
+ end
110
+
111
+ #
112
+ def reset_password(options = {})
113
+ options = argument_cleaner(required_params: %i( username ), optional_params: %i( answer ), options: options )
114
+ authenticated_get cmd: "resetpassword", **options
115
+ end
116
+
117
+ # api.update_password userid: 57181, password: "IChanged123"
118
+ def update_password(options = {})
119
+ options = argument_cleaner(required_params: %i( userid password ), optional_params: %i( token oldpassword ), options: options )
120
+ authenticated_get cmd: "updatepassword", **options
121
+ end
122
+
123
+ # ISSUE: This should be a POST method as it's storing data
124
+ # api.put_key entityid: 57031, name: 'secret_key_1', value: "Super Secret"
125
+ def put_key(options = {})
126
+ options = argument_cleaner(required_params: %i( entityid name value ), optional_params: %i( ), options: options )
127
+ authenticated_get cmd: "putkey", **options
128
+ end
129
+
130
+ # api.get_key entityid: 57031, name: 'secret_key_1'
131
+ def get_key(options = {})
132
+ options = argument_cleaner(required_params: %i( entityid name ), optional_params: %i( ), options: options )
133
+ authenticated_get cmd: "getkey", **options
134
+ end
135
+
136
+ # This requires a key to exist with the given keyname, see putkey
137
+ # not sure what its used for yet
138
+ # api.compute_hmac
139
+ def compute_hmac(options = {})
140
+ options = argument_cleaner(required_params: %i( domainid keyname message ), optional_params: %i( algorithm format ), options: options )
141
+ options[:message] = "$VAR_USERID#{options[:message]}$VAR_SECRETTime$VAR_TIME"
142
+ authenticated_get cmd: "computeHMAC", **options
143
+ end
144
+
145
+ private
146
+ def set_token_expiration(minutes)
147
+ Time.now + (minutes.to_i * 60 )
148
+ end
149
+
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,91 @@
1
+ module Agilix
2
+ module Buzz
3
+ module Commands
4
+ module Course
5
+
6
+ # api.copy_courses [{courseid: 60982, domainid: 57025}]
7
+ def copy_courses(items = [])
8
+ options = items.map do |item|
9
+ argument_cleaner(required_params: %i( courseid domainid ), optional_params: %i( action depth reference status roleid title type startdate enddate days term indexrule ), options: item )
10
+ end
11
+ authenticated_bulk_post cmd: "copycourses", root_node: "course", body: options
12
+ end
13
+
14
+ # api.create_courses title: "Starter Course", domainid: 57025
15
+ def create_courses(items = [])
16
+ options = items.map do |item|
17
+ item[:schema] ||= 3 # should default to 3, 2 is old news
18
+ argument_cleaner(required_params: %i( title domainid schema ), optional_params: %i(reference status roleid type startdate enddate days term indexrule data ), options: item )
19
+ end
20
+ authenticated_bulk_post cmd: "createcourses", root_node: "course", body: options
21
+ end
22
+
23
+ # ISSUE: documentation on request format is inconsistent, not sure if it is bulk post or normal post format. in one place rood node is request, in other its course
24
+ # api.create_demo_course courseid: 60982, domainid: 57025, title: "Demo Course", daysoffset: 60
25
+ def create_demo_course(options = {})
26
+ options = argument_cleaner(required_params: %i( courseid domainid ), optional_params: %i( schema reference title daysoffset usermap ), options: options )
27
+ authenticated_post cmd: "createdemocourse", **options
28
+ end
29
+
30
+ # ISSUE: get request should be delete, put, patch
31
+ # api.deactivate_course
32
+ def deactivate_course(options = {})
33
+ options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
34
+ authenticated_get cmd: "deactivatecourse", **options
35
+ end
36
+
37
+ # ISSUE: Why so different than deactivate course
38
+ # api.delete_courses [{courseid: 60994}]
39
+ def delete_courses(items = [])
40
+ options = items.map do |item|
41
+ argument_cleaner(required_params: %i( courseid ), optional_params: %i(), options: item )
42
+ end
43
+ authenticated_bulk_post cmd: "deletecourses", root_node: "course", body: options
44
+ end
45
+
46
+ # api.get_course2 courseid: 60994
47
+ def get_course2(options = {})
48
+ options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( select version ), options: options )
49
+ authenticated_get cmd: "getcourse2", **options
50
+ end
51
+ alias_method :get_course, :get_course2
52
+
53
+ # api.get_course_history courseid: 60994
54
+ def get_course_history(options = {})
55
+ options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
56
+ authenticated_get cmd: "getcoursehistory", **options
57
+ end
58
+
59
+ # api.list_courses domainid: 5
60
+ def list_courses(options = {})
61
+ options[:domainid] ||= 0
62
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select text query subtype subscriptionmode subscriptiondomainid ), options: options )
63
+ authenticated_get cmd: "listcourses", **options
64
+ end
65
+
66
+ # api.merge_courses courseid: 60994
67
+ def merge_courses(items = [])
68
+ options = items.map do |item|
69
+ argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: item )
70
+ end
71
+ authenticated_bulk_post cmd: "mergecourses", root_node: "course", body: options
72
+ end
73
+
74
+ # api.restore_course courseid: 60994
75
+ def restore_course(options = {})
76
+ options = argument_cleaner(required_params: %i( courseid ), optional_params: %i( ), options: options )
77
+ authenticated_get cmd: "restorecourse", **options
78
+ end
79
+
80
+ # api.update_courses [{courseid: 60994, title: "Updated Course"}]
81
+ def update_courses(items = [])
82
+ options = items.map do |item|
83
+ argument_cleaner(required_params: %i( courseid ), optional_params: %i( domainid title reference type baseid startdate enddate days term indexrule schema data ), options: item )
84
+ end
85
+ authenticated_bulk_post cmd: "updatecourses", root_node: "course", body: options
86
+ end
87
+
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,85 @@
1
+ module Agilix
2
+ module Buzz
3
+ module Commands
4
+ module Domain
5
+
6
+ # api.create_domains [{name: "BuzzTest1", userspace: 'buzz-test-fc-1', parentid: '57025'}]
7
+ def create_domains(items = [])
8
+ options = items.map do |item|
9
+ argument_cleaner(required_params: %i( name userspace parentid ), optional_params: %i( reference flags data ), options: item )
10
+ end
11
+ authenticated_bulk_post cmd: "createdomains", root_node: 'domain', body: options
12
+ end
13
+
14
+ # api.delete_domain domainid: '57031'
15
+ def delete_domain(options = {})
16
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
17
+ authenticated_get cmd: "deletedomain", **options
18
+ end
19
+
20
+ # api.get_domain domainid: '57025'
21
+ def get_domain2(options = {})
22
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( select ), options: options )
23
+ authenticated_get cmd: "getdomain2", **options
24
+ end
25
+ alias_method :get_domain, :get_domain2
26
+
27
+ # api.get_domain_content domainid: '57025'
28
+ def get_domain_content(options = {})
29
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
30
+ authenticated_get cmd: "getdomaincontent", **options
31
+ end
32
+
33
+ # api.get_domain_enrollment_metrics domainid: '57025'
34
+ def get_domain_enrollment_metrics(options = {})
35
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( skipempty ), options: options )
36
+ authenticated_get cmd: "getdomainenrollmentmetrics", **options
37
+ end
38
+
39
+ # api.get_domain_parent_list domainid: '57025'
40
+ def get_domain_parent_list(options = {})
41
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
42
+ authenticated_get cmd: "getdomainparentlist", **options
43
+ end
44
+
45
+ # api.get_domain_settings domainid: '57025', path: "AgilixBuzzSettings.xml"
46
+ def get_domain_settings(options = {})
47
+ options = argument_cleaner(required_params: %i( domainid path ), optional_params: %i( includesource ), options: options )
48
+ authenticated_get cmd: "getdomainsettings", **options
49
+ end
50
+ # Optional can use settings in a POST to set settings attributes if needed.
51
+
52
+ # api.get_domain_stats domainid: '57025', options: "users|courses"
53
+ def get_domain_stats(options = {})
54
+ # options = 'users|courses|activecourses|sections|enrollments|activeenrollments|activestudents'
55
+ options = argument_cleaner(required_params: %i( domainid options ), optional_params: %i( includesource ), options: options )
56
+
57
+ authenticated_get cmd: "getdomainstats", **options
58
+ end
59
+
60
+ # api.list_domains domainid: '0' # all domains for user
61
+ # api.list_domains domainid: '57025'
62
+ def list_domains(options = {})
63
+ options[:domainid] ||= 0
64
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( includedescendantdomains limit show select text query ), options: options )
65
+ authenticated_get cmd: "listdomains", **options
66
+ end
67
+
68
+ # api.restore_domain domainid: '57031'
69
+ def restore_domain(options = {})
70
+ options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
71
+ authenticated_get cmd: "restoredomain", **options
72
+ end
73
+
74
+ # api.update_domains [{ domainid: "57031", name: "BuzzTestUpdated1", userspace: 'buzz-test-fc-1', parentid: '57025'}]
75
+ def update_domains(items)
76
+ options = items.map do |item|
77
+ argument_cleaner(required_params: %i( domainid ), optional_params: %i( name userspace parentid reference flags data ), options: item )
78
+ end
79
+ authenticated_bulk_post cmd: "updatedomains", root_node: 'domain', body: options
80
+ end
81
+
82
+ end
83
+ end
84
+ end
85
+ end