Class: Io::Flow::V0::Models::PermissionCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Used to test an integration’s permissions, including identifying the authentication technique that will be used for similar requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PermissionCheck

Returns a new instance of PermissionCheck.



34262
34263
34264
34265
34266
34267
34268
34269
34270
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34262

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:authentication_technique, :roles, :behaviors, :routes], 'PermissionCheck')
  @authentication_technique = (x = opts.delete(:authentication_technique); x.is_a?(::Io::Flow::V0::Models::AuthenticationTechnique) ? x : ::Io::Flow::V0::Models::AuthenticationTechnique.apply(x))
  @user = (x = opts.delete(:user); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::User) ? x : ::Io::Flow::V0::Models::User.new(x)))
  @roles = HttpClient::Preconditions.assert_class('roles', opts.delete(:roles), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FlowRole) ? x : ::Io::Flow::V0::Models::FlowRole.from_json(x)) }
  @behaviors = HttpClient::Preconditions.assert_class('behaviors', opts.delete(:behaviors), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FlowBehavior) ? x : ::Io::Flow::V0::Models::FlowBehavior.apply(x)) }
  @routes = HttpClient::Preconditions.assert_class('routes', opts.delete(:routes), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PermittedRoute) ? x : ::Io::Flow::V0::Models::PermittedRoute.new(x)) }
end

Instance Attribute Details

#authentication_techniqueObject (readonly)

Returns the value of attribute authentication_technique.



34260
34261
34262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34260

def authentication_technique
  @authentication_technique
end

#behaviorsObject (readonly)

Returns the value of attribute behaviors.



34260
34261
34262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34260

def behaviors
  @behaviors
end

#rolesObject (readonly)

Returns the value of attribute roles.



34260
34261
34262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34260

def roles
  @roles
end

#routesObject (readonly)

Returns the value of attribute routes.



34260
34261
34262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34260

def routes
  @routes
end

#userObject (readonly)

Returns the value of attribute user.



34260
34261
34262
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34260

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34276
34277
34278
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34276

def copy(incoming={})
  PermissionCheck.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



34280
34281
34282
34283
34284
34285
34286
34287
34288
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34280

def to_hash
  {
    :authentication_technique => authentication_technique.value,
    :user => user.nil? ? nil : user.to_hash,
    :roles => roles.map { |o| o.to_hash },
    :behaviors => behaviors.map { |o| o.value },
    :routes => routes.map { |o| o.to_hash }
  }
end

#to_jsonObject



34272
34273
34274
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34272

def to_json
  JSON.dump(to_hash)
end