Module: WolfCore::Integrations::CustomValueApiOperations
- Includes:
- HttpOperations
- Included in:
- ClientApiOperations
- Defined in:
- lib/wolf_core/application/integrations/custom_value_api_operations.rb
Instance Method Summary collapse
- #create_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_requirement_id:, query: nil) ⇒ Object
- #create_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_requirement_id:, error_data: nil, query: nil) ⇒ Object
- #fetch_custom_value(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, query: nil) ⇒ Object
- #fetch_custom_value!(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) ⇒ Object
- #fetch_custom_values(wolf_token:, tenant:, wolf_platform_url:, query: nil) ⇒ Object
- #fetch_custom_values!(wolf_token:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) ⇒ Object
- #update_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_value_id:, query: nil) ⇒ Object
- #update_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_value_id:, error_data: nil, query: nil) ⇒ Object
- #upsert_custom_value(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:) ⇒ Object
- #upsert_custom_value!(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:, error_message:, error_data: nil) ⇒ Object
Methods included from HttpOperations
#async_http_get, #async_http_patch, #async_http_post, #async_http_put, #http_get, #http_patch, #http_post, #http_put, #parse_http_response, #parsed_http_get, #parsed_http_patch, #parsed_http_post, #parsed_http_put, #response_success?, #safe_http_get, #safe_http_patch, #safe_http_post, #safe_http_put, #validate_http_response
Methods included from LoggingUtils
Methods included from AsyncUtils
Methods included from ExceptionOperations
Instance Method Details
#create_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_requirement_id:, query: nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 67 def create_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_requirement_id:, query: nil) query ||= {} parsed_http_post( headers: { "Authorization" => "Bearer #{wolf_token}" }, query: query.merge(tenant: tenant), url: "#{wolf_platform_url}/api/v2/custom_requirements/#{custom_requirement_id}/custom_values", body: custom_value ) end |
#create_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_requirement_id:, error_data: nil, query: nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 52 def create_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_requirement_id:, error_data: nil, query: nil) response = create_custom_value( wolf_token: wolf_token, custom_value: custom_value, tenant: tenant, wolf_platform_url: wolf_platform_url, custom_requirement_id: custom_requirement_id, query: query ) error_data ||= {} validate_http_response(response: response, message: , error_data: error_data.merge(custom_value: custom_value)) response end |
#fetch_custom_value(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, query: nil) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 43 def fetch_custom_value(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, query: nil) query ||= {} parsed_http_get( headers: { "Authorization" => "Bearer #{wolf_token}" }, url: "#{wolf_platform_url}/api/v2/custom_values/#{custom_value_id}", query: query.merge(tenant: tenant) ) end |
#fetch_custom_value!(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 29 def fetch_custom_value!(wolf_token:, custom_value_id:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) response = fetch_custom_value( wolf_token: wolf_token, custom_value_id: custom_value_id, tenant: tenant, wolf_platform_url: wolf_platform_url, query: query ) error_data ||= {} validate_http_response(response: response, message: , error_data: error_data.merge(custom_value_id: custom_value_id)) response.body.dig("data", "table", "custom_responses") end |
#fetch_custom_values(wolf_token:, tenant:, wolf_platform_url:, query: nil) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 20 def fetch_custom_values(wolf_token:, tenant:, wolf_platform_url:, query: nil) query ||= {} parsed_http_get( headers: { "Authorization" => "Bearer #{wolf_token}" }, url: "#{wolf_platform_url}/api/v2/custom_values", query: query.merge(tenant: tenant) ) end |
#fetch_custom_values!(wolf_token:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 8 def fetch_custom_values!(wolf_token:, tenant:, wolf_platform_url:, error_message:, error_data: nil, query: nil) response = fetch_custom_values( wolf_token: wolf_token, tenant: tenant, wolf_platform_url: wolf_platform_url, query: query ) error_data ||= {} validate_http_response(response: response, message: , error_data: error_data.merge(query: query)) response.body.dig("data", "table", "custom_responses") end |
#update_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_value_id:, query: nil) ⇒ Object
93 94 95 96 97 98 99 100 101 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 93 def update_custom_value(wolf_token:, custom_value:, tenant:, wolf_platform_url:, custom_value_id:, query: nil) query ||= {} parsed_http_put( headers: { "Authorization" => "Bearer #{wolf_token}" }, query: query.merge(tenant: tenant), url: "#{wolf_platform_url}/api/v2/custom_values/#{custom_value_id}", body: custom_value ) end |
#update_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_value_id:, error_data: nil, query: nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 78 def update_custom_value!(wolf_token:, custom_value:, tenant:, wolf_platform_url:, error_message:, custom_value_id:, error_data: nil, query: nil) response = update_custom_value( wolf_token: wolf_token, custom_value: custom_value, tenant: tenant, wolf_platform_url: wolf_platform_url, custom_value_id: custom_value_id, query: query ) error_data ||= {} validate_http_response(response: response, message: , error_data: error_data.merge(custom_value_id: custom_value_id, custom_value: custom_value)) response end |
#upsert_custom_value(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 143 def upsert_custom_value(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:) response = fetch_custom_values( wolf_token: wolf_token, tenant: tenant, wolf_platform_url: wolf_platform_url, query: query ) return response unless response_success?(response) custom_values = response.body.dig("data", "table", "custom_responses") response = if custom_values&.any? operation_type = :update custom_value_id = custom_values.first["id"] update_custom_value( wolf_platform_url: wolf_platform_url, tenant: tenant, wolf_token: wolf_token, custom_value_id: custom_value_id, custom_value: custom_value ) else operation_type = :create create_custom_value( wolf_platform_url: wolf_platform_url, tenant: tenant, wolf_token: wolf_token, custom_requirement_id: custom_requirement_id, custom_value: custom_value ) end OpenStruct.new({ operation_type: operation_type, response: response }) end |
#upsert_custom_value!(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:, error_message:, error_data: nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/wolf_core/application/integrations/custom_value_api_operations.rb', line 103 def upsert_custom_value!(wolf_token:, tenant:, wolf_platform_url:, query:, custom_requirement_id:, custom_value:, error_message:, error_data: nil) response = fetch_custom_values( wolf_token: wolf_token, tenant: tenant, wolf_platform_url: wolf_platform_url, query: query ) error_data ||= {} validate_http_response(response: response, message: , error_data: error_data.merge(query: query)) custom_values = response.body.dig("data", "table", "custom_responses") response = if custom_values&.any? operation_type = :update custom_value_id = custom_values.first["id"] update_custom_value!( wolf_platform_url: wolf_platform_url, tenant: tenant, wolf_token: wolf_token, custom_value_id: custom_value_id, custom_value: custom_value, error_message: , error_data: error_data ) else operation_type = :create create_custom_value!( wolf_platform_url: wolf_platform_url, tenant: tenant, wolf_token: wolf_token, custom_requirement_id: custom_requirement_id, custom_value: custom_value, error_message: , error_data: error_data ) end { operation_type: operation_type, response: response } end |