Skip to content

Commit 1b613fa

Browse files
authored
Merge pull request #14 from contentstack/sync_api
Sync API
2 parents 86e6f1c + 27eab2c commit 1b613fa

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ coverage
77
\.yardoc
88
.DS_Store
99
.bundle/
10-
*/rspec_results.html
10+
*/rspec_results.html
11+
vendor/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
## CHANGELOG
22
------------------------------------------------
33

4+
## Version 0.3.0
5+
### Date: 17th-Mar-2021
6+
### New Features
7+
- Sync API module support added
8+
9+
------------------------------------------------
410
## Version 0.2.0
511

612
### New Features

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2012-2019 Contentstack. All Rights Reserved
3+
Copyright (c) 2012-2021 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

lib/contentstack/api.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def self.get_assets(asset_uid=nil)
4040
send_request(path)
4141
end
4242

43+
def self.get_sync_items(query)
44+
path = "/stacks/sync"
45+
send_request(path, query)
46+
end
47+
4348
private
4449
def self.send_request(path, q=nil)
4550
q ||= {}

lib/contentstack/sync_result.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'active_support/core_ext'
2+
3+
module Contentstack
4+
class SyncResult
5+
attr_reader :items
6+
attr_reader :sync_token
7+
attr_reader :pagination_token
8+
attr_reader :total_count
9+
attr_reader :skip
10+
attr_reader :limit
11+
12+
def initialize(sync_result)
13+
if sync_result.nil?
14+
@items = []
15+
@sync_token = nil
16+
@pagination_token = nil
17+
@total_count = 0
18+
@skip = 0
19+
@limit = 100
20+
else
21+
@items = sync_result["items"] || []
22+
@sync_token = sync_result["sync_token"] || nil
23+
@pagination_token = sync_result["pagination_token"] || nil
24+
@total_count = sync_result["total_count"] || 0
25+
@skip = sync_result["skip"] || 0
26+
@limit = sync_result["limit"] || 100
27+
end
28+
end
29+
end
30+
end

lib/contentstack/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Contentstack
2-
VERSION = "0.2.0"
2+
VERSION = "0.3.0"
33
end

0 commit comments

Comments
 (0)