Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update __init__.py #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions api_class/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
# -*- coding: utf-8 -*-
import json
import urllib
import urllib2
import requests


class Api(object):
def __init__(self, srv_address='http://195.64.222.86:8087'):
def __init__(self, srv_address='http://***:8082'):
self.srv_address = srv_address

def call_api(self, model, params):
encoded_params = urllib.urlencode(params)
api_url = "{0}/rest_api/v2/{1}/".format(self.srv_address, model)
print(api_url)
print('pamams: {0}'.format(encoded_params))
req = urllib2.Request(api_url, encoded_params)
response = urllib2.urlopen(req)
result = response.read()
obj= json.loads(result)
req = requests.post(url=api_url, data=params)
obj= req.json()
if obj.get('error'):
print(u'Произошла ошибка на стороне биллинга:{0}'.format(obj['error']))
return obj
return obj