Skip to content

Instantly share code, notes, and snippets.

@nil96
Created December 10, 2021 19:01
Show Gist options
  • Save nil96/27a294bb84d569a66c47b2282886a955 to your computer and use it in GitHub Desktop.
Save nil96/27a294bb84d569a66c47b2282886a955 to your computer and use it in GitHub Desktop.
require "uri"
require "json"
require "net/http"
url = URI("https://staging-runner.cargoes.com/services/Default/ContainerTypes/Create")
# SELECT concat (Code,'$', Description,'$', Mode,'$', ContainerType,'$', TEU,'$', Active,'$', TenantId ,'$', InsertUserId, '$', UpdateUserId,'$', IATAClass,'$')
# FROM ContainerTypes where TenantId = 143
File.foreach('container_create_staging.csv').with_index do |line, line_num|
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
arr = line.split('$');
if(arr[5]==nil || arr[5]=="" || arr[5]=="0" || arr[5]==0)
arr[5] = false
else
arr[5] = true
end
request = Net::HTTP::Post.new(url)
request["authority"] = "staging-runner.cargoes.com"
request["sec-ch-ua"] = "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""
request["accept"] = "application/json, text/javascript, */*; q=0.01"
request["content-type"] = "application/json"
request["x-requested-with"] = "XMLHttpRequest"
request["sec-ch-ua-mobile"] = "?0"
request["user-agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36"
request["sec-ch-ua-platform"] = "\"macOS\""
request["origin"] = "https://staging-runner.cargoes.com"
request["sec-fetch-site"] = "same-origin"
request["sec-fetch-mode"] = "cors"
request["sec-fetch-dest"] = "empty"
request["referer"] = "https://staging-runner.cargoes.com/Default/ContainerTypes"
request["accept-language"] = "en-GB,en-US;q=0.9,en;q=0.8"
# request["cookie"] = "_gcl_au=1.1.1266271950.1632407035; _ga=GA1.2.690476173.1632407039; gaconnector_GA_Client_ID=690476173.1632407039; _hjid=278a1159-0499-4c3f-a2f2-3fda1fbef722; _hjSessionUser_2326152=eyJpZCI6ImFlZTY1NGY1LWRlMTgtNTUxNS1iN2Q3LWE3Yzc5NzM5OTVkMyIsImNyZWF0ZWQiOjE2MzgxODUwNTI3NTcsImV4aXN0aW5nIjp0cnVlfQ==; gaconnector_gclid=; gaconnector_fc_source=(direct); gaconnector_lc_source=(direct); gaconnector_fc_medium=(none); gaconnector_lc_medium=(none); gaconnector_fc_campaign=(direct); gaconnector_lc_campaign=(direct); gaconnector_fc_term=(not set); gaconnector_lc_term=(not set); gaconnector_fc_content=(not set); gaconnector_lc_content=(not set); gaconnector_fc_landing=https://demo.cargoes.com/; gaconnector_lc_landing=https://demo.cargoes.com/; gaconnector_fc_referrer=(not set); gaconnector_lc_referrer=(not set); gaconnector_fc_channel=Direct; gaconnector_lc_channel=Direct; gaconnector_ip_address=-; gaconnector_OS=Mac OS 10.15.7; gaconnector_device=desktop; gaconnector_browser=Chrome 96.0.4664.55; gaconnector_city=Kolkata; gaconnector_country=India; gaconnector_country_code=IN; gaconnector_region=West Bengal; gaconnector_time_zone=Asia/Kolkata; gaconnector_latitude=22.518; gaconnector_longitude=88.3832; gaconnector_all_traffic_sources=(direct)/(none), (direct)/(none); gaconnector_pages_visited_list=/runner|/|/login|/logistics; gaconnector_page_visits=4; gaconnector_time_passed=120414263; .AspNetCore.Antiforgery.pUOXNTmQ6pM=CfDJ8MRqjtC4arRBhYRw_XNteLBEgFhzECwboSYLVIAEkHEzuydNYckgsvvQ1bHQoN6CudWJ8M4HAuiKI8Og4eCfhzw_J9B8X1OGRw9wcW9LYNHoF0g3zTSzd-6zyd8JZxMO4buDWqmT1CBAO3cJCqp-d7Q; .AspNetAuth=CfDJ8MRqjtC4arRBhYRw_XNteLB08uIzKXk9zTAgRhCgxq4vquu807A_D1VYnQrK56sCCbwl23aOBvn3jctqgbRFNxLvbfrxCLaS9OmcqhgE4ZRMHUOmWCBFkfOMcDztMKVAOlA8e1cpWVmMUlmer8mQ4Es_6AcJY_xSQRy8y8sxjJpvq911cWG4u8O7bkRj7B22RSC-oEKAhINI4lfbv_WkToke36mwyDCi12q_6sQjjkbH7f3qMyAZi1KYNIayRBdHLNcQYsHIsqtlwAJQ2-q140_FQn7o7NwdB24p5KAS2L28XAye7NxTPYMS2gdLAjHCWDNXaUXIYEhXmJTt-MXMJ1g; sessionId=CfDJ8MRqjtC4arRBhYRw_XNteLB08uIzKXk9zTAgRhCgxq4vquu807A_D1VYnQrK56sCCbwl23aOBvn3jctqgbRFNxLvbfrxCLaS9OmcqhgE4ZRMHUOmWCBFkfOMcDztMKVAOlA8e1cpWVmMUlmer8mQ4Es_6AcJY_xSQRy8y8sxjJpvq911cWG4u8O7bkRj7B22RSC-oEKAhINI4lfbv_WkToke36mwyDCi12q_6sQjjkbH7f3qMyAZi1KYNIayRBdHLNcQYsHIsqtlwAJQ2-q140_FQn7o7NwdB24p5KAS2L28XAye7NxTPYMS2gdLAjHCWDNXaUXIYEhXmJTt-MXMJ1g"
request["cookie"] = "_gcl_au=1.1.1266271950.1632407035; _ga=GA1.2.690476173.1632407039; gaconnector_GA_Client_ID=690476173.1632407039; _hjid=278a1159-0499-4c3f-a2f2-3fda1fbef722; _hjSessionUser_2326152=eyJpZCI6ImFlZTY1NGY1LWRlMTgtNTUxNS1iN2Q3LWE3Yzc5NzM5OTVkMyIsImNyZWF0ZWQiOjE2MzgxODUwNTI3NTcsImV4aXN0aW5nIjp0cnVlfQ==; gaconnector_gclid=; gaconnector_fc_source=(direct); gaconnector_lc_source=(direct); gaconnector_fc_medium=(none); gaconnector_lc_medium=(none); gaconnector_fc_campaign=(direct); gaconnector_lc_campaign=(direct); gaconnector_fc_term=(not set); gaconnector_lc_term=(not set); gaconnector_fc_content=(not set); gaconnector_lc_content=(not set); gaconnector_fc_landing=https://demo.cargoes.com/; gaconnector_lc_landing=https://demo.cargoes.com/; gaconnector_fc_referrer=(not set); gaconnector_lc_referrer=(not set); gaconnector_fc_channel=Direct; gaconnector_lc_channel=Direct; gaconnector_ip_address=-; gaconnector_OS=Mac OS 10.15.7; gaconnector_device=desktop; gaconnector_browser=Chrome 96.0.4664.55; gaconnector_city=Kolkata; gaconnector_country=India; gaconnector_country_code=IN; gaconnector_region=West Bengal; gaconnector_time_zone=Asia/Kolkata; gaconnector_latitude=22.518; gaconnector_longitude=88.3832; gaconnector_all_traffic_sources=(direct)/(none), (direct)/(none); gaconnector_pages_visited_list=/runner|/|/login|/logistics; gaconnector_page_visits=4; gaconnector_time_passed=120414263; .AspNetCore.Antiforgery.pUOXNTmQ6pM=CfDJ8MRqjtC4arRBhYRw_XNteLBEgFhzECwboSYLVIAEkHEzuydNYckgsvvQ1bHQoN6CudWJ8M4HAuiKI8Og4eCfhzw_J9B8X1OGRw9wcW9LYNHoF0g3zTSzd-6zyd8JZxMO4buDWqmT1CBAO3cJCqp-d7Q; sessionId=CfDJ8MRqjtC4arRBhYRw_XNteLB08uIzKXk9zTAgRhCgxq4vquu807A_D1VYnQrK56sCCbwl23aOBvn3jctqgbRFNxLvbfrxCLaS9OmcqhgE4ZRMHUOmWCBFkfOMcDztMKVAOlA8e1cpWVmMUlmer8mQ4Es_6AcJY_xSQRy8y8sxjJpvq911cWG4u8O7bkRj7B22RSC-oEKAhINI4lfbv_WkToke36mwyDCi12q_6sQjjkbH7f3qMyAZi1KYNIayRBdHLNcQYsHIsqtlwAJQ2-q140_FQn7o7NwdB24p5KAS2L28XAye7NxTPYMS2gdLAjHCWDNXaUXIYEhXmJTt-MXMJ1g; .AspNetAuth=CfDJ8MRqjtC4arRBhYRw_XNteLAwRPXLk4kpJEmaVGu4o-Ct_N_qxrPxxwuOT0FCILwE3Bj2yV7s6JlnNlljO99Ccu_jWTe-UqoP2Q4Bzi1hmMzqwhATJYHVcFGcyKCjvI8hEfQZLGx3xfkn0ooSvzBDMzoCTNgKK9nLRPam5zm0RRqJBn_jjMtLY8See0xXigAKHIpDPo4B4ra_oGz2EndU9IDgubo23AkF72wsYPSquRKyJWVdGXKyxVX955wwdo8pmPAgj2qMZ2TR-23mwMgeB6Qd_FiPzX5hgE6g61ol9XUbx4GKeLiJWMZwSdgYjGQfAvWXYo-sXBJ0EY3Stern0pY"
request.body = JSON.dump({
"Entity": {
"Code": arr[0],
"Description": arr[1],
"Mode": arr[2],
"ContainerType": arr[3],
"Teu": arr[4].to_f,
"IATAClass": arr[9],
"Active": arr[5]
}
})
puts request.body
response = https.request(request)
puts response.read_body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment