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
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
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
#!/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)
 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()