syncano 3.1.4 → 4.0.0.alpha
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 +7 -0
- data/.gitignore +4 -1
- data/.rspec +2 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +25 -1
- data/Guardfile +22 -4
- data/README.md +68 -447
- data/Rakefile +48 -5
- data/circle.yml +10 -0
- data/lib/active_attr/dirty.rb +3 -17
- data/lib/active_attr/typecasting/hash_typecaster.rb +34 -0
- data/lib/active_attr/typecasting_override.rb +29 -0
- data/lib/syncano.rb +53 -92
- data/lib/syncano/api.rb +13 -0
- data/lib/syncano/connection.rb +97 -0
- data/lib/syncano/model/associations.rb +121 -0
- data/lib/syncano/{active_record/association → model/associations}/base.rb +5 -5
- data/lib/syncano/{active_record/association → model/associations}/belongs_to.rb +6 -6
- data/lib/syncano/{active_record/association → model/associations}/has_many.rb +15 -9
- data/lib/syncano/{active_record/association → model/associations}/has_one.rb +4 -4
- data/lib/syncano/model/base.rb +257 -0
- data/lib/syncano/{active_record → model}/callbacks.rb +16 -13
- data/lib/syncano/{active_record → model}/scope_builder.rb +53 -69
- data/lib/syncano/query_builder.rb +19 -129
- data/lib/syncano/resources.rb +126 -0
- data/lib/syncano/resources/base.rb +304 -300
- data/lib/syncano/resources/collection.rb +19 -223
- data/lib/syncano/resources/space.rb +29 -0
- data/lib/syncano/schema.rb +86 -0
- data/lib/syncano/schema/attribute_definition.rb +83 -0
- data/lib/syncano/schema/resource_definition.rb +36 -0
- data/lib/syncano/scope.rb +10 -0
- data/lib/syncano/version.rb +3 -4
- data/spec/integration/syncano_spec.rb +228 -0
- data/spec/spec_helper.rb +15 -9
- data/spec/unit/api_spec.rb +5 -0
- data/spec/unit/connection_spec.rb +137 -0
- data/spec/unit/query_builder_spec.rb +75 -0
- data/spec/unit/resources/collection_spec.rb +36 -0
- data/spec/unit/resources/space_spec.rb +28 -0
- data/spec/unit/resources_base_spec.rb +185 -0
- data/spec/unit/schema/attribute_definition_spec.rb +18 -0
- data/spec/unit/schema/resource_definition_spec.rb +25 -0
- data/spec/unit/schema_spec.rb +3532 -0
- data/spec/unit/syncano_spec.rb +63 -0
- data/syncano.gemspec +8 -14
- metadata +85 -210
- data/lib/generators/syncano/install_generator.rb +0 -17
- data/lib/generators/syncano/templates/initializers/syncano.rb +0 -7
- data/lib/syncano/active_record/associations.rb +0 -112
- data/lib/syncano/active_record/base.rb +0 -318
- data/lib/syncano/batch_queue.rb +0 -58
- data/lib/syncano/batch_queue_element.rb +0 -33
- data/lib/syncano/clients/base.rb +0 -123
- data/lib/syncano/clients/rest.rb +0 -79
- data/lib/syncano/clients/sync.rb +0 -164
- data/lib/syncano/errors.rb +0 -17
- data/lib/syncano/jimson_client.rb +0 -66
- data/lib/syncano/packets/auth.rb +0 -27
- data/lib/syncano/packets/base.rb +0 -70
- data/lib/syncano/packets/call.rb +0 -34
- data/lib/syncano/packets/call_response.rb +0 -33
- data/lib/syncano/packets/error.rb +0 -19
- data/lib/syncano/packets/message.rb +0 -30
- data/lib/syncano/packets/notification.rb +0 -39
- data/lib/syncano/packets/ping.rb +0 -12
- data/lib/syncano/resources/admin.rb +0 -26
- data/lib/syncano/resources/api_key.rb +0 -108
- data/lib/syncano/resources/data_object.rb +0 -316
- data/lib/syncano/resources/folder.rb +0 -88
- data/lib/syncano/resources/notifications/base.rb +0 -103
- data/lib/syncano/resources/notifications/create.rb +0 -20
- data/lib/syncano/resources/notifications/destroy.rb +0 -20
- data/lib/syncano/resources/notifications/message.rb +0 -9
- data/lib/syncano/resources/notifications/update.rb +0 -24
- data/lib/syncano/resources/project.rb +0 -96
- data/lib/syncano/resources/role.rb +0 -11
- data/lib/syncano/resources/subscription.rb +0 -12
- data/lib/syncano/resources/user.rb +0 -65
- data/lib/syncano/response.rb +0 -22
- data/lib/syncano/sync_connection.rb +0 -133
- data/spec/admins_spec.rb +0 -16
- data/spec/api_keys_spec.rb +0 -34
- data/spec/collections_spec.rb +0 -67
- data/spec/data_objects_spec.rb +0 -113
- data/spec/folders_spec.rb +0 -39
- data/spec/notifications_spec.rb +0 -43
- data/spec/projects_spec.rb +0 -35
- data/spec/roles_spec.rb +0 -13
- data/spec/sync_resources_spec.rb +0 -35
- data/spec/syncano_spec.rb +0 -9
data/lib/syncano/errors.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
# General errors
|
3
|
-
class BaseError < RuntimeError
|
4
|
-
end
|
5
|
-
|
6
|
-
# Class represeting errors returned by the Syncano API
|
7
|
-
class ApiError < BaseError
|
8
|
-
end
|
9
|
-
|
10
|
-
# Class representing errors during connections
|
11
|
-
class ConnectionError < BaseError
|
12
|
-
end
|
13
|
-
|
14
|
-
# Class representing timeout errors
|
15
|
-
class TimeoutError < BaseError
|
16
|
-
end
|
17
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# Overwritten module from Jimson gem
|
2
|
-
module Jimson
|
3
|
-
# Overwritten helper from Jimson gem
|
4
|
-
class ClientHelper
|
5
|
-
# Overwritten send_single_request method, so it now adds header with the user agent
|
6
|
-
# @return [Array] collection of responses
|
7
|
-
def send_single_request(method, args)
|
8
|
-
post_data = {
|
9
|
-
'jsonrpc' => JSON_RPC_VERSION,
|
10
|
-
'method' => method,
|
11
|
-
'params' => args,
|
12
|
-
'id' => self.class.make_id
|
13
|
-
}.to_json
|
14
|
-
resp = RestClient.post(@url, post_data, content_type: 'application/json', user_agent: "syncano-ruby-#{Syncano::VERSION}")
|
15
|
-
if resp.nil? || resp.body.nil? || resp.body.empty?
|
16
|
-
raise Jimson::ClientError::InvalidResponse.new
|
17
|
-
end
|
18
|
-
|
19
|
-
return resp.body
|
20
|
-
|
21
|
-
rescue Exception, StandardError
|
22
|
-
raise Jimson::ClientError::InternalError.new($!)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Overwritten send_batch_request method, so it now adds header with the user agent
|
26
|
-
# @return [Array] collection of responses
|
27
|
-
def send_batch_request(batch)
|
28
|
-
post_data = batch.to_json
|
29
|
-
resp = RestClient.post(@url, post_data, content_type: 'application/json', user_agent: "syncano-ruby-#{Syncano::VERSION}")
|
30
|
-
if resp.nil? || resp.body.nil? || resp.body.empty?
|
31
|
-
raise Jimson::ClientError::InvalidResponse.new
|
32
|
-
end
|
33
|
-
|
34
|
-
return resp.body
|
35
|
-
end
|
36
|
-
|
37
|
-
# Overwritten send_batch method, so it now returns collection of responses
|
38
|
-
# @return [Array] collection of responses
|
39
|
-
def send_batch
|
40
|
-
batch = @batch.map(&:first) # get the requests
|
41
|
-
response = send_batch_request(batch)
|
42
|
-
|
43
|
-
begin
|
44
|
-
responses = JSON.parse(response)
|
45
|
-
rescue
|
46
|
-
raise Jimson::ClientError::InvalidJSON.new(json)
|
47
|
-
end
|
48
|
-
|
49
|
-
process_batch_response(responses)
|
50
|
-
responses = @batch
|
51
|
-
|
52
|
-
@batch = []
|
53
|
-
|
54
|
-
responses
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Overwritten Request class from Jimson gem
|
59
|
-
class Request
|
60
|
-
# Overwritten as_json method which solves bug with serialization batch requests
|
61
|
-
# @return [Hash]
|
62
|
-
def as_json(options = {})
|
63
|
-
to_h
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/syncano/packets/auth.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing auth packets used in communication with the Sync Server
|
4
|
-
class Auth < Syncano::Packets::Base
|
5
|
-
attr_reader :message_id, :status, :error
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::Auth object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.message_id = 'auth'
|
12
|
-
self.status = attributes[:result]
|
13
|
-
self.error = attributes[:error]
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns true if is an auth packet
|
17
|
-
# @return [TrueClass, FalseClass]
|
18
|
-
def auth?
|
19
|
-
true
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
attr_writer :message_id, :status, :error
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/syncano/packets/base.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
# Module used as a scope for classes representing packets
|
3
|
-
module Packets
|
4
|
-
# Base class for representing packets used in communication with the Sync Server
|
5
|
-
class Base
|
6
|
-
attr_reader :object, :timestamp
|
7
|
-
|
8
|
-
# Constructor for Syncano::Packets::Base object
|
9
|
-
# @param [Hash] attributes
|
10
|
-
def initialize(attributes)
|
11
|
-
super()
|
12
|
-
self.timestamp = attributes[:timestamp]
|
13
|
-
self.object = attributes[:object]
|
14
|
-
end
|
15
|
-
|
16
|
-
# Proxy method for creating instance of proper subclass
|
17
|
-
# @param [Hash] data
|
18
|
-
# @return [Syncano::Packets::Base]
|
19
|
-
def self.instantize_packet(data)
|
20
|
-
mapping = {
|
21
|
-
auth: ::Syncano::Packets::Auth,
|
22
|
-
call: ::Syncano::Packets::Call,
|
23
|
-
callresponse: ::Syncano::Packets::CallResponse,
|
24
|
-
error: ::Syncano::Packets::Error,
|
25
|
-
message: ::Syncano::Packets::Message,
|
26
|
-
new: ::Syncano::Packets::Notification,
|
27
|
-
change: ::Syncano::Packets::Notification,
|
28
|
-
delete: ::Syncano::Packets::Notification,
|
29
|
-
ping: ::Syncano::Packets::Ping
|
30
|
-
}
|
31
|
-
|
32
|
-
mapping[data[:type].to_sym].new(data)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns true if is a notification packet
|
36
|
-
# @return [TrueClass, FalseClass]
|
37
|
-
def notification?
|
38
|
-
false
|
39
|
-
end
|
40
|
-
|
41
|
-
# Returns true if is a ping packet
|
42
|
-
# @return [TrueClass, FalseClass]
|
43
|
-
def ping?
|
44
|
-
false
|
45
|
-
end
|
46
|
-
|
47
|
-
# Returns true if is a call response packet
|
48
|
-
# @return [TrueClass, FalseClass]
|
49
|
-
def call_response?
|
50
|
-
false
|
51
|
-
end
|
52
|
-
|
53
|
-
# Returns true if is a message packet
|
54
|
-
# @return [TrueClass, FalseClass]
|
55
|
-
def message?
|
56
|
-
false
|
57
|
-
end
|
58
|
-
|
59
|
-
# Returns true if is an auth packet
|
60
|
-
# @return [TrueClass, FalseClass]
|
61
|
-
def auth?
|
62
|
-
false
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
attr_writer :object, :timestamp
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/syncano/packets/call.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing call packets used in communication with the Sync Server
|
4
|
-
class Call < Syncano::Packets::Base
|
5
|
-
attr_reader :message_id, :resource_name, :method_name, :data
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::Call object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.resource_name = attributes[:resource_name]
|
12
|
-
self.method_name = attributes[:method_name]
|
13
|
-
self.data = attributes[:data]
|
14
|
-
self.message_id = attributes[:message_id] || rand(10**12)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Overwritten method for preparing hash for json serialization
|
18
|
-
# @param [Hash] options
|
19
|
-
# @return [Hash]
|
20
|
-
def as_json(options = {})
|
21
|
-
{
|
22
|
-
type: 'call',
|
23
|
-
method: "#{resource_name}.#{method_name}",
|
24
|
-
params: data,
|
25
|
-
message_id: message_id.to_s
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_writer :message_id, :resource_name, :method_name, :data
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing call response packets used in communication with the Sync Server
|
4
|
-
class CallResponse < Syncano::Packets::Base
|
5
|
-
attr_reader :message_id, :data, :result
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::CallResponse object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.message_id = attributes[:message_id]
|
12
|
-
self.data = attributes[:data]
|
13
|
-
self.result = attributes[:result]
|
14
|
-
end
|
15
|
-
|
16
|
-
# Prepares hash in response format
|
17
|
-
# @return [Hash]
|
18
|
-
def to_response
|
19
|
-
data.merge(result: result)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns true if is a call response packet
|
23
|
-
# @return [TrueClass, FalseClass]
|
24
|
-
def call_response?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_writer :message_id, :data, :result
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing error packets used in communication with the Sync Server
|
4
|
-
class Error < Syncano::Packets::Base
|
5
|
-
attr_reader :error
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::Error object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.error = attributes[:error]
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
attr_writer :error
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing message packets used in communication with the Sync Server
|
4
|
-
class Message < Syncano::Packets::Base
|
5
|
-
attr_accessor :id, :source, :target, :data
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::Message object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.id = attributes[:id]
|
12
|
-
self.source = attributes[:source]
|
13
|
-
self.target = attributes[:target]
|
14
|
-
self.data = attributes[:data]
|
15
|
-
end
|
16
|
-
|
17
|
-
# Returns true if is a notification packet
|
18
|
-
# @return [TrueClass, FalseClass]
|
19
|
-
def notification?
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns true if is a message packet
|
24
|
-
# @return [TrueClass, FalseClass]
|
25
|
-
def message?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing notification packets used in communication with the Sync Server
|
4
|
-
class Notification < Syncano::Packets::Base
|
5
|
-
attr_reader :id, :type, :channel, :source, :target, :data
|
6
|
-
|
7
|
-
# Constructor for Syncano::Packets::Notification object
|
8
|
-
# @param [Hash] attributes
|
9
|
-
def initialize(attributes)
|
10
|
-
super(attributes)
|
11
|
-
self.id = attributes[:id]
|
12
|
-
self.type = attributes[:type]
|
13
|
-
self.channel = attributes[:channel]
|
14
|
-
self.source = attributes[:source]
|
15
|
-
self.target = attributes[:target]
|
16
|
-
|
17
|
-
if type == 'change'
|
18
|
-
self.data = {
|
19
|
-
added: attributes[:add],
|
20
|
-
updated: attributes[:replace],
|
21
|
-
deleted: attributes[:delete]
|
22
|
-
}
|
23
|
-
else
|
24
|
-
self.data = attributes[:data]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns true if is a notification packet
|
29
|
-
# @return [TrueClass, FalseClass]
|
30
|
-
def notification?
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
attr_writer :id, :type, :channel, :source, :target, :data
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/syncano/packets/ping.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Packets
|
3
|
-
# Class representing ping packets used in communication with the Sync Server
|
4
|
-
class Ping < Syncano::Packets::Base
|
5
|
-
# Returns true if is a ping packet
|
6
|
-
# @return [TrueClass, FalseClass]
|
7
|
-
def ping?
|
8
|
-
true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Resources
|
3
|
-
# Admin resource
|
4
|
-
class Admin < ::Syncano::Resources::Base
|
5
|
-
# Wrapper for api "get_one" method with admin_email as a key
|
6
|
-
# @param [Syncano::Clients::Base] client
|
7
|
-
# @param [String] email
|
8
|
-
# @param [Hash] scope_parameters
|
9
|
-
# @param [Hash] conditions
|
10
|
-
# @return [Syncano::Resources::Admin]
|
11
|
-
def self.find_by_email(client, email, scope_parameters = {}, conditions = {})
|
12
|
-
perform_find(client, :admin_email, email, scope_parameters, conditions)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Wrapper for api "new" method
|
16
|
-
# Creates object in Syncano
|
17
|
-
# @param [Syncano::Clients::Base] client
|
18
|
-
# @param [Hash] attributes
|
19
|
-
# @return [Syncano::Resources::Base]
|
20
|
-
def self.create(client, attributes)
|
21
|
-
perform_create(client, nil, attributes)
|
22
|
-
all(client, map_to_scope_parameters(attributes)).last
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
class Syncano
|
2
|
-
module Resources
|
3
|
-
# Api key resource
|
4
|
-
class ApiKey < ::Syncano::Resources::Base
|
5
|
-
# Overwritten constructor with initializing associated role object
|
6
|
-
# @param [Syncano::Clients::Base] client
|
7
|
-
# @param [Hash] attributes
|
8
|
-
def initialize(client, attributes = {})
|
9
|
-
super(client, attributes)
|
10
|
-
if @attributes[:role].is_a?(Hash)
|
11
|
-
@attributes[:role] = ::Syncano::Resources::Role.new(client, @attributes[:role])
|
12
|
-
end
|
13
|
-
|
14
|
-
if @saved_attributes[:role].is_a?(Hash)
|
15
|
-
@saved_attributes[:role] = ::Syncano::Resources::Role.new(client, @saved_attributes[:role])
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# Wrapper for api "authorize" method
|
20
|
-
# @param [String] permission
|
21
|
-
# @return [Syncano::Resources::Base]
|
22
|
-
def authorize(permission)
|
23
|
-
perform_authorize(nil, permission: permission)
|
24
|
-
self
|
25
|
-
end
|
26
|
-
|
27
|
-
# Wrapper for api "authorize" method
|
28
|
-
# @param [Jimson::BatchClient] batch_client
|
29
|
-
# @param [String] permission
|
30
|
-
# @return [Syncano::Resources::Base]
|
31
|
-
def batch_authorize(batch_client, permission)
|
32
|
-
perform_authorize(batch_client, permission: permission)
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
# Wrapper for api "deauthorize" method
|
37
|
-
# @param [String] permission
|
38
|
-
# @return [Syncano::Resources::Base]
|
39
|
-
def deauthorize(permission)
|
40
|
-
perform_deauthorize(nil, permission: permission)
|
41
|
-
self
|
42
|
-
end
|
43
|
-
|
44
|
-
# Wrapper for api "deauthorize" method
|
45
|
-
# @param [Jimson::BatchClient] batch_client
|
46
|
-
# @param [String] permission
|
47
|
-
# @return [Syncano::Resources::Base]
|
48
|
-
def batch_deauthorize(batch_client, permission)
|
49
|
-
perform_deauthorize(batch_client, permission: permission)
|
50
|
-
self
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
# Prepares attributes to synchronizing with Syncano
|
56
|
-
# @param [Hash] attributes
|
57
|
-
# @return [Hash] prepared attributes
|
58
|
-
def self.attributes_to_sync(attributes)
|
59
|
-
attributes = attributes.dup
|
60
|
-
attributes.delete(:role)
|
61
|
-
|
62
|
-
attributes
|
63
|
-
end
|
64
|
-
|
65
|
-
# Name of attribute used as primary key
|
66
|
-
# @return [Symbol]
|
67
|
-
def self.primary_key_name
|
68
|
-
:api_client_id
|
69
|
-
end
|
70
|
-
|
71
|
-
# Executes proper find request
|
72
|
-
# @param [Syncano::Clients::Base] client
|
73
|
-
# @param [Symbol, String] key_name
|
74
|
-
# @param [Integer, String] key
|
75
|
-
# @param [Hash] scope_parameters
|
76
|
-
# @param [Hash] conditions
|
77
|
-
# @return [Syncano::Response]
|
78
|
-
def self.perform_find(client, key_name, key, scope_parameters, conditions)
|
79
|
-
key_parameters = key.present? ? { key_name.to_sym => key } : {}
|
80
|
-
make_request(client, nil, :find, conditions.merge(scope_parameters.merge(key_parameters)))
|
81
|
-
end
|
82
|
-
|
83
|
-
# Executes proper update request
|
84
|
-
# @param [Jimson::BatchClient] batch_client
|
85
|
-
# @param [Hash] attributes
|
86
|
-
# @return [Syncano::Response]
|
87
|
-
def perform_update(batch_client, attributes)
|
88
|
-
self.class.make_request(client, batch_client, :update_description, self.class.attributes_to_sync(attributes).merge(self.class.primary_key_name.to_sym => primary_key))
|
89
|
-
end
|
90
|
-
|
91
|
-
# Executes proper authorize request
|
92
|
-
# @param [Jimson::BatchClient] batch_client
|
93
|
-
# @param [Hash] parameters
|
94
|
-
# @return [Syncano::Response]
|
95
|
-
def perform_authorize(batch_client, parameters)
|
96
|
-
self.class.make_request(client, batch_client, :authorize, parameters.merge(self.class.primary_key_name.to_sym => primary_key))
|
97
|
-
end
|
98
|
-
|
99
|
-
# Executes proper deauthorize request
|
100
|
-
# @param [Jimson::BatchClient] batch_client
|
101
|
-
# @param [Hash] parameters
|
102
|
-
# @return [Syncano::Response]
|
103
|
-
def perform_deauthorize(batch_client, parameters)
|
104
|
-
self.class.make_request(client, batch_client, :deauthorize, parameters.merge(self.class.primary_key_name.to_sym => primary_key))
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|