Skip to content

Commit

Permalink
initiation
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Nov 18, 2019
1 parent a279aee commit 0fcb479
Show file tree
Hide file tree
Showing 16 changed files with 365 additions and 1 deletion.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import frappe
import requests
from requests import HTTPError
from requests.auth import HTTPBasicAuth


@frappe.whitelist()
def test_listintegration(username, password, authenticationtype):
servicemethod = 'GET'
serviceurl = "https://listing-external-sit.hepsiburada.com"
serviceendpoint = "/listings/merchantid"

servicecontenttype = "application/json"

merchantid = "509778cf-7104-4c7f-850f-e14fdf5beb70"
serviceresource = "/" + merchantid

servicedata = ""

req = Request(serviceurl + serviceendpoint + serviceresource, authenticationtype=)
req.add_header("Content-Type", servicecontenttype)
req.method = servicemethod

# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = HTTPBasicAuthHandler()
auth_handler.add_password(user='framras_dev',
passwd='Fr12345!')
opener = build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
install_opener(opener)

try:
response = urlopen(req)
with response as f:
return f.read().decode('utf-8')
except HTTPError as e:
return 'The server couldn\'t fulfill the request. ' + 'Error code: ' + str(e.code)
except URLError as e:
return 'We failed to reach a server. ' + 'Reason: ' + e.reason
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2019, Framras AS-Izmir and contributors
// For license information, please see license.txt

frappe.ui.form.on('hepsiburadacom Integration Company Settings', {
// refresh: function(frm) {

// }
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"creation": "2019-11-18 23:40:30.295654",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"company",
"integration_warehouse",
"integration_section",
"username",
"password",
"merchantid"
],
"fields": [
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"unique": 1
},
{
"fieldname": "integration_warehouse",
"fieldtype": "Link",
"label": "Integration Warehouse",
"options": "Warehouse"
},
{
"fieldname": "integration_section",
"fieldtype": "Section Break",
"label": "Integration Settings"
},
{
"fieldname": "username",
"fieldtype": "Data",
"label": "User Name"
},
{
"fieldname": "password",
"fieldtype": "Data",
"label": "Password"
},
{
"fieldname": "merchantid",
"fieldtype": "Data",
"label": "Merchant ID"
}
],
"modified": "2019-11-18 23:40:30.295654",
"modified_by": "Administrator",
"module": "Hepsiburadacom",
"name": "hepsiburadacom Integration Company Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Framras AS-Izmir and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document


class hepsiburadacomIntegrationCompanySettings(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Framras AS-Izmir and Contributors
# See license.txt
from __future__ import unicode_literals

# import frappe
import unittest


class TesthepsiburadacomIntegrationCompanySettings(unittest.TestCase):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2019, Framras AS-Izmir and contributors
// For license information, please see license.txt

frappe.ui.form.on('hepsiburadacom Integration Settings', {
// refresh: function(frm) {

// }
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"creation": "2019-11-18 20:34:38.267097",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"contenttype",
"listintegration_section",
"list_host",
"column_break_5",
"list_testhost",
"orderintegration_section",
"order_host",
"column_break_11",
"order_testhost",
"financeintegration_section",
"finance_host"
],
"fields": [
{
"fieldname": "contenttype",
"fieldtype": "Data",
"label": "Content Type"
},
{
"fieldname": "listintegration_section",
"fieldtype": "Section Break",
"label": "List Integration"
},
{
"fieldname": "list_host",
"fieldtype": "Data",
"label": "Host"
},
{
"fieldname": "column_break_5",
"fieldtype": "Column Break"
},
{
"fieldname": "list_testhost",
"fieldtype": "Data",
"label": "Test Host"
},
{
"fieldname": "orderintegration_section",
"fieldtype": "Section Break",
"label": "Order Integration"
},
{
"fieldname": "order_host",
"fieldtype": "Data",
"label": "Host"
},
{
"fieldname": "column_break_11",
"fieldtype": "Column Break"
},
{
"fieldname": "order_testhost",
"fieldtype": "Data",
"label": "Test Host"
},
{
"fieldname": "financeintegration_section",
"fieldtype": "Section Break",
"label": "Finance Integration"
},
{
"fieldname": "finance_host",
"fieldtype": "Data",
"label": "Host"
}
],
"issingle": 1,
"modified": "2019-11-18 23:35:26.478395",
"modified_by": "Administrator",
"module": "Hepsiburadacom",
"name": "hepsiburadacom Integration Settings",
"owner": "[email protected]",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Framras AS-Izmir and contributors
# For license information, please see license.txt

from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document


class hepsiburadacomIntegrationSettings(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Framras AS-Izmir and Contributors
# See license.txt
from __future__ import unicode_literals

# import frappe
import unittest


class TesthepsiburadacomIntegrationSettings(unittest.TestCase):
pass
47 changes: 47 additions & 0 deletions hepsiburadacom/hepsiburadacom/sil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from urllib.request import Request, urlopen, HTTPBasicAuthHandler, build_opener, install_opener
from urllib.error import URLError, HTTPError
import base64

servicemethod = 'GET'
serviceprotocol = "https://"
servicehost = "listing-external-sit.hepsiburada.com"
serviceurl = serviceprotocol + servicehost
serviceendpoint = "/listings/merchantid"

servicecontenttype = "application/json"

merchantid = "509778cf-7104-4c7f-850f-e14fdf5beb70"
serviceresource = "/" + merchantid

username = 'framras_dev'
password = 'Fr12345!'

servicedata = ""

req = Request(serviceurl + serviceendpoint + serviceresource)
req.add_header("Content-Type", servicecontenttype)
req.add_header("Host", servicehost)
userAndPass = base64.b64encode(username + ":" + password).decode("utf-8")
req.add_header("Authorization", userAndPass)
req.method = servicemethod

# Create an OpenerDirector with support for Basic HTTP Authentication...
# auth_handler = HTTPBasicAuthHandler()
# auth_handler.add_password(realm=None,
# uri=serviceurl,
# user=username,
# passwd=password)
# opener = build_opener(auth_handler)
# # ...and install it globally so it can be used with urlopen.
# install_opener(opener)

print(req.headers)
print(req.full_url)
try:
response = urlopen(req)
with response as f:
print(f.read().decode('utf-8'))
except HTTPError as e:
print('The server couldn\'t fulfill the request. ' + 'Error code: ' + str(e.code))
except URLError as e:
print('We failed to reach a server. ' + 'Reason: ' + e.reason)
50 changes: 50 additions & 0 deletions hepsiburadacom/hepsiburadacom/sil2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import requests
from requests import HTTPError
from requests.auth import HTTPBasicAuth

servicemethod = 'GET'
serviceprotocol = "https://"
servicehost = "listing-external-sit.hepsiburada.com"
serviceurl = serviceprotocol + servicehost
serviceendpoint = "/listings/merchantid"

servicecontenttype = "application/json"

merchantid = "509778cf-7104-4c7f-850f-e14fdf5beb70"
serviceresource = "/" + merchantid

username = 'framras_dev'
password = 'Fr12345!'

servicedata = ""
try:
r = requests.get(serviceurl + serviceendpoint + serviceresource, auth=HTTPBasicAuth(username, password))
with r:
print(r.text)
except HTTPError as e:
print('The server couldn\'t fulfill the request. ' + 'Error code: ' + str(e.code))
finally:
print(r.request.url)
print(r.request.headers)

# req = Request()
# req.add_header("Content-Type", servicecontenttype)
# req.add_header("Host", servicehost)
# userAndPass = base64.b64encode(username + ":" + password).decode("utf-8")
# req.add_header("Authorization", userAndPass)
# req.method = servicemethod

# Create an OpenerDirector with support for Basic HTTP Authentication...
# auth_handler = HTTPBasicAuthHandler()
# auth_handler.add_password(realm=None,
# uri=serviceurl,
# user=username,
# passwd=password)
# opener = build_opener(auth_handler)
# # ...and install it globally so it can be used with urlopen.
# install_opener(opener)

# print(req.headers)
# print(req.full_url)

# response = urlopen(req)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
frappe
frappe
requests

0 comments on commit 0fcb479

Please sign in to comment.