コード例 #1
0
class BrandMemberCard:
    def __init__(self):
        self.rest_client = RestClient(is_shop=False)

    def create_brand_member_card(self, data=None, **kwargs):
        response = self.rest_client.post("/_api/v1/cards/member/brand", data=data, **kwargs)
        return response

    def get_brand_member_card(self, card_id, **kwargs):
        response = self.rest_client.get("/_api/v1/cards/member/brand/{}".format(card_id), **kwargs)
        return response
コード例 #2
0
def main():
	# This allows us to use a plain HTTP callback
	os.environ['DEBUG'] = "1"
	rc = RestClient(ssl_verify=False)

	try:
		result = rc.get("https://localhost:9090/api/test")
		pprint(result)
		result = rc.post("https://localhost:9091/api/info", payload=result)
		pprint(result)
	except RestError as e:
		print e.value
	except Exception as e:
		print e
コード例 #3
0
ファイル: role.py プロジェクト: tsjcxd/saas_pro_python_new
class Role:
    def __init__(self):
        self.rest_client = RestClient(is_shop=True)

    def get_role(self):
        response = self.rest_client.get("/_api/v1/common/role/normal")
        return response
コード例 #4
0
class BrandShop:
    def __init__(self):
        self.rest_client = RestClient(is_shop=False)

    def get_brand_shop(self, params, **kwarg):
        response = self.rest_client.get("/_api/v1/shop", params=params, **kwarg)
        return response
コード例 #5
0
class Department:
    def __init__(self):
        self.rest_client = RestClient(is_shop=True)

    def get_department(self):
        response = self.rest_client.get("/_api/v1/department")
        return response
コード例 #6
0
class SwitchShop:
    def __init__(self):
        self.rest_client = RestClient(is_shop=False)

    def switch_shop(self, data):
        response = self.rest_client.put("/_api/v1/account/switch/shop",
                                        data=data)
        return response
コード例 #7
0
class Salesperson:

    def __init__(self, is_shop=True):
        self.rest_client = RestClient()

    def create_sales_person(self, data=None, **kwargs):
        response = self.rest_client.post("/_api/v1/staff/shop/basic", data=data, **kwargs)
        return response
コード例 #8
0
class Shop:
    def __init__(self):
        self.rest_client = RestClient(is_shop=True)

    def get_shop(self):
        response = self.rest_client.get(
            "/_api/v1/staff/brand/select_shop_list")
        return response
コード例 #9
0
class ShopMember:
    def __init__(self):
        self.rest_client = RestClient(is_shop=True)

    def create_shop_member(self, data=None, **kwargs):
        response = self.rest_client.post("/_api/v1/member",
                                         data=data,
                                         **kwargs)
        return response
コード例 #10
0
def main():
    # This allows us to use a plain HTTP callback
    os.environ['DEBUG'] = "1"
    rc = RestClient(ssl_verify=False)

    try:
        result = {
            "date": time.time(),
            "results": {},
            "summary": {
                "failed": 1,
                "runtime": 0.0004849433898925781,
                "tests": 4
            }
        }
        result = rc.post("https://localhost:9091/api/info", payload=result)
        pprint(result)
    except RestError as e:
        print e.value
    except Exception as e:
        print e
コード例 #11
0
def main():
	# This allows us to use a plain HTTP callback
	os.environ['DEBUG'] = "1"
	rc = RestClient(ssl_verify=False)

	try:
		result = {
			"date": time.time(),
			"results": {
			},
			"summary": {
				"failed": 0,
				"runtime": 0.0004849433898925781,
				"tests": 4
			}
		}
		result = rc.post("https://localhost:9091/api/info", payload=result)
		pprint(result)
	except RestError as e:
		print e.value
	except Exception as e:
		print e
コード例 #12
0
ファイル: shock-client.py プロジェクト: MG-RAST/ShockClient
#!/usr/bin/env python3

import os, sys
from restclient.restclient import RestClient


# Example constructor with OAuth
c = RestClient("https://shock.mg-rast.org", headers = { "Authorization" : "mgrast "+os.environ['MGRKEY'] })

# err = sc.Put_request("/node/"+node_id+"/acl/public_read", nil, &sqr_p)

for node_id in sys.argv[1:]:

    response = c.put("node/"+node_id+"/acl/public_read", debug=True)

    print(response.json())


コード例 #13
0
def api_atom():
    rc = RestClient(ssl_verify=False, timeout=0.1)
    feed = AtomFeed('Recent Articles',
                    feed_url=request.url,
                    url=request.url_root)

    try:
        result = rc.get("https://localhost:9091/api/info")
        results = reversed(collections.OrderedDict(sorted(result.items())))

        curr_id = None
        curr_item = None
        curr_timestamp = None
        curr_summary = None
        curr_status = None
        curr_tests = None

        next_id = None
        next_item = None
        next_timestamp = None
        next_summary = None
        next_status = None
        next_tests = None

        from_timestamp = None
        to_timestamp = None
        first_print = False

        curr_id = results.next()
        while True:
            print "--> iteration start"
            curr_item = result[curr_id]
            curr_timestamp = curr_item['date']
            curr_summary = curr_item['summary']
            curr_status = curr_summary['failed']
            if to_timestamp == None:
                print "1 set to_timestamp %s" % curr_timestamp
                to_timestamp = curr_timestamp
            print "curr_id %s" % curr_id
            try:
                next_id = results.next()
                next_item = result[next_id]
                next_timestamp = next_item['date']
                next_summary = next_item['summary']
                next_status = next_summary['failed']
                print "4 set from_timestamp %s" % curr_timestamp
                from_timestamp = curr_item['date']
                curr_tests = curr_summary['tests']
                print "next_id %s" % next_id

                if curr_status != next_status:
                    print_item(
                        feed, curr_status, curr_tests,
                        make_external("https://localhost:9091/api/info/%s" %
                                      curr_id), from_timestamp, to_timestamp,
                        first_print)
                    to_timestamp = curr_timestamp
                    print "2 set to_timestamp %s" % curr_timestamp
                    first_print = False
                curr_id = next_id

            except:
                print "--> exception"
                print "3 set from_timestamp %s" % curr_timestamp
                from_timestamp = curr_item['date']
                curr_tests = curr_summary['tests']

                print_item(
                    feed, curr_status, curr_tests,
                    make_external("https://localhost:9091/api/info/%s" %
                                  curr_id), from_timestamp, to_timestamp,
                    first_print)
                first_print = False

                curr_id = next_id
                break

            print "<-- iteration end"

        return feed.get_response()

    except RestError as e:
        print e.value
    except Exception as e:
        print e

    return feed.get_response()
コード例 #14
0
 def __init__(self):
     self.rest_client = RestClient(is_shop=False)
コード例 #15
0
 def __init__(self, is_shop=True):
     self.rest_client = RestClient()
コード例 #16
0
def api_atom():
	rc = RestClient(ssl_verify=False, timeout=0.1)
	feed = AtomFeed('Recent Articles', feed_url=request.url, url=request.url_root)

        try:
                result = rc.get("https://localhost:9091/api/info")
		results = reversed( collections.OrderedDict( sorted( result.items() ) ) )

		curr_id = None
		curr_item = None
		curr_timestamp = None
		curr_summary = None
		curr_status = None
		curr_tests = None

		next_id = None
		next_item = None
		next_timestamp = None
		next_summary = None
		next_status = None
		next_tests = None

		from_timestamp = None
		to_timestamp = None
		first_print = False

		curr_id = results.next()
		while True:
			print "--> iteration start"
			curr_item = result[curr_id]
			curr_timestamp = curr_item['date']
			curr_summary = curr_item['summary']
			curr_status = curr_summary['failed']
			if to_timestamp == None:
				print "1 set to_timestamp %s" % curr_timestamp
				to_timestamp = curr_timestamp
			print "curr_id %s" % curr_id
			try:
				next_id = results.next()
				next_item = result[next_id]
				next_timestamp = next_item['date']
				next_summary = next_item['summary']
				next_status = next_summary['failed']
				print "4 set from_timestamp %s" % curr_timestamp
				from_timestamp = curr_item['date']
				curr_tests = curr_summary['tests']
				print "next_id %s" % next_id

				if curr_status != next_status:
					print_item(feed, curr_status, curr_tests, make_external("https://localhost:9091/api/info/%s" % curr_id), from_timestamp, to_timestamp, first_print)
					to_timestamp = curr_timestamp
					print "2 set to_timestamp %s" % curr_timestamp
					first_print = False
				curr_id = next_id

			except:
				print "--> exception"
				print "3 set from_timestamp %s" % curr_timestamp
				from_timestamp = curr_item['date']
				curr_tests = curr_summary['tests']

				print_item(feed, curr_status, curr_tests, make_external("https://localhost:9091/api/info/%s" % curr_id), from_timestamp, to_timestamp, first_print)
				first_print = False

				curr_id = next_id
				break

			print "<-- iteration end"

		return feed.get_response()

        except RestError as e:
                print e.value
        except Exception as e:
                print e

	return feed.get_response()