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

Add short links #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ res = client.LandingsForWebsite.get(10, 22, limit=100)
res = client.DeeplinksManage.create(22, 10, ulp='https://admitad.com/some/', subid='AS32djkd31')
```

### ShortLinks ###

###### Get short link ######

```python
res = client.ShortLinks.post(link='https://ad.admitad.com/g/some/')
```

### Referrals ###

###### List of referrals ######
Expand Down
1 change: 1 addition & 0 deletions admitad/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
from admitad.items.retag import *
from admitad.items.broken_links import *
from admitad.items.tickets import *
from admitad.items.short_links import *
3 changes: 3 additions & 0 deletions admitad/items/coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CouponsBase(Item):
'campaign_category': lambda x: Item.sanitize_integer_array(x, 'campaign_category', blank=True),
'category': lambda x: Item.sanitize_integer_array(x, 'category', blank=True),
'type': lambda x: Item.sanitize_string_value(x, 'type', blank=True),
'search': lambda x: Item.sanitize_string_value(x, 'search', blank=True),
}


Expand All @@ -39,6 +40,7 @@ def get(self, **kwargs):
campaign (list of int)
campaign_category (list of int)
category (list of int)
search (str)
type (str)
limit (int)
offset (int)
Expand Down Expand Up @@ -95,6 +97,7 @@ def get(self, _id, **kwargs):
campaign (list of int)
campaign_category (list of int)
category (list of int)
search (str)
type (str)
limit (int)
offset (int)
Expand Down
30 changes: 30 additions & 0 deletions admitad/items/short_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# coding: utf-8
from __future__ import unicode_literals

from admitad.items.base import Item


__all__ = [
'ShortLinks'
]


class ShortLinks(Item):

SCOPE = 'short_links'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCOPE must be 'short_link' not 'short_links'


URL = Item.prepare_url('shortlink/modify/')

GET_FIELDS = {
'link': lambda x: Item.sanitize_string_value(x, 'link'),
}

def post(self, link, **kwargs):
"""
Args:
link (str)

"""
data = Item.sanitize_fields(self.GET_FIELDS, link=link)

return self.transport.post().set_data(data).request(url=self.URL)