Skip to content

Commit bb03e28

Browse files
authored
Merge pull request #8 from contentstack/develop
Region support and remove timestamp for cdn request
2 parents ffa4c0a + 14f7e3d commit bb03e28

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

lib/contentstack.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require "contentstack/version"
44
require "contentstack/client"
5+
require "contentstack/region"
56
require "util"
67

78

@@ -11,6 +12,10 @@
1112
# gem install contentstack
1213
# == Initialize the Stack
1314
# @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
15+
# == Initialize the Stack for EU region
16+
# @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name", {"region": Contentstack::Region::EU })
17+
# == Initialize the Stack for custom host
18+
# @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name", {"host": "https://custom-cdn.contentstack.com" })
1419
# == Usage
1520
# ==== Get single entry
1621
# @stack.content_type('blog').entry('<entry_uid_here>').fetch

lib/contentstack/api.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
module Contentstack
88
class API
9-
def self.init_api(api_key, access_token, environment)
10-
@host = "https://cdn.contentstack.io"
9+
def self.init_api(api_key, access_token, environment,host)
10+
@host = host
1111
@api_version = '/v3'
1212
@environment = environment
1313
@headers = {api_key: api_key, access_token: access_token, user_agent: "ruby-sdk/#{Contentstack::VERSION}", environment: @environment}
@@ -43,7 +43,6 @@ def self.send_request(path, q=nil)
4343
q ||= {}
4444

4545
q.merge!(@headers)
46-
q.merge!({timestamp: Time.now.to_i})
4746

4847
query = "?" + q.to_query
4948
# puts "Request URL:- #{@host}#{@api_version}#{path}#{query} \n\n"

lib/contentstack/region.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Contentstack
2+
class Region
3+
EU='eu'
4+
US='us'
5+
end
6+
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.0.3"
2+
VERSION = "0.0.4"
33
end

0 commit comments

Comments
 (0)