Class: Centaman::Service::CreateUdf

Inherits:
Centaman::Service show all
Defined in:
lib/centaman/service/create_udf.rb

Constant Summary

Constants inherited from Wrapper

Wrapper::DEFAULT_TIMEOUT_TIME

Instance Attribute Summary collapse

Attributes inherited from Wrapper

#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user

Instance Method Summary collapse

Methods inherited from Centaman::Service

#after_post, #fetch_all, #post, #put

Methods inherited from Wrapper

#generate_token, #headers, #initialize, #options, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout

Constructor Details

This class inherits a constructor from Centaman::Wrapper

Instance Attribute Details

#member_codeObject (readonly)

Returns the value of attribute member_code.



3
4
5
# File 'lib/centaman/service/create_udf.rb', line 3

def member_code
  @member_code
end

#udfsObject (readonly)

Returns the value of attribute udfs.



3
4
5
# File 'lib/centaman/service/create_udf.rb', line 3

def udfs
  @udfs
end

Instance Method Details

#after_init(args) ⇒ Object



5
6
7
8
# File 'lib/centaman/service/create_udf.rb', line 5

def after_init(args)
  @udfs = args.fetch(:udfs, [])
  @member_code = args[:member_code]
end

#build_udf_body(udf) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/centaman/service/create_udf.rb', line 14

def build_udf_body(udf)
  {
    'Value': udf.value,
    'FieldName': udf.field_name,
    'FieldType': udf.field_type,
    'FieldLength': udf.field_length,
    'TabName': udf.tab_name,
  }
end

#endpointObject



10
11
12
# File 'lib/centaman/service/create_udf.rb', line 10

def endpoint
  "/udf_services/UDFMember?memberCode=#{member_code}"
end

#options_hashObject



24
25
26
# File 'lib/centaman/service/create_udf.rb', line 24

def options_hash
  udfs.map { |udf| build_udf_body(udf) }.to_json
end