contentstack 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2c05a60239a20793be053c9afa3684e579f1b744
4
- data.tar.gz: 002d29d76b307264a6353cb13b6a7d07a5372d35
2
+ SHA256:
3
+ metadata.gz: cc7aab29132806e94f049f49be18f7bbb285423f13a949dfc6ea8288d4d52a51
4
+ data.tar.gz: d290838ee0df496dedf6cc1912fd180cc646b018041bac733afccce190a9dd24
5
5
  SHA512:
6
- metadata.gz: 3fa5770932d3c6e4de5dbb6c90790f3ae889802863403c45a4aff7338d1ca591ec72e6920798fb81f85c3c745ef33e770898e852e3ad68bf9c490b356a957a17
7
- data.tar.gz: 63b98d912dcbf97dc4b1e34f326ef125a53fcccdb1748211126ff4a3f311ab5d65d762216703a8fdda46cb8c3a2871d16d210c323561373bdad6cdf76cd76f31
6
+ metadata.gz: ff4947a727bcb0f195c7e9712b6072192942c2de8be5edfc420ec16176924eaf24f61ddef3ee13dca2659d1c5c3abefe598dbf43efee9ae1e81d9571dcddad3f
7
+ data.tar.gz: 9625bc07c44f7cc31d7f43212fc3f9cb9cfe108063b894e9cd17d1c49fa8b45d68f37d828796333448033c8d05db2cdd8ab4e02693e34db3e70cd51f56cf45bf
data/.gitignore CHANGED
@@ -5,3 +5,6 @@ doc
5
5
  spec-integration
6
6
  coverage
7
7
  \.yardoc
8
+ .DS_Store
9
+ .bundle/
10
+ */rspec_results.html
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gem "rspec"
5
+ gem "webmock"
6
+ gem "simplecov"
7
+ gem "activesupport"
@@ -0,0 +1,59 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (6.0.2.2)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 0.7, < 2)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ zeitwerk (~> 2.2)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ concurrent-ruby (1.1.6)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ diff-lcs (1.3)
16
+ docile (1.3.2)
17
+ hashdiff (1.0.1)
18
+ i18n (1.8.2)
19
+ concurrent-ruby (~> 1.0)
20
+ minitest (5.14.0)
21
+ public_suffix (4.0.4)
22
+ rspec (3.9.0)
23
+ rspec-core (~> 3.9.0)
24
+ rspec-expectations (~> 3.9.0)
25
+ rspec-mocks (~> 3.9.0)
26
+ rspec-core (3.9.1)
27
+ rspec-support (~> 3.9.1)
28
+ rspec-expectations (3.9.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.9.0)
31
+ rspec-mocks (3.9.1)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.9.0)
34
+ rspec-support (3.9.2)
35
+ safe_yaml (1.0.5)
36
+ simplecov (0.18.5)
37
+ docile (~> 1.1)
38
+ simplecov-html (~> 0.11)
39
+ simplecov-html (0.12.2)
40
+ thread_safe (0.3.6)
41
+ tzinfo (1.2.7)
42
+ thread_safe (~> 0.1)
43
+ webmock (3.8.3)
44
+ addressable (>= 2.3.6)
45
+ crack (>= 0.3.2)
46
+ hashdiff (>= 0.4.0, < 2.0.0)
47
+ zeitwerk (2.3.0)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ activesupport
54
+ rspec
55
+ simplecov
56
+ webmock
57
+
58
+ BUNDLED WITH
59
+ 2.1.4
data/README.md CHANGED
@@ -22,13 +22,13 @@ Or you can run this command in your terminal (you might need administrator privi
22
22
  To start using the SDK in your application, you will need to initialize the stack by providing the values for the keys given in the code snippet below.
23
23
 
24
24
  # with default region
25
- client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
25
+ client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
26
26
 
27
27
  # with specific region
28
- client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name",{"region": Contentstack::Region::EU})
28
+ client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
29
29
 
30
30
  # with custom host
31
- client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
31
+ client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
32
32
 
33
33
 
34
34
 
@@ -61,7 +61,7 @@ A publishing environment corresponds to one or more deployment servers or a cont
61
61
 
62
62
  To initialize the SDK, you need to provide values for the keys given in the snippet below:
63
63
 
64
- stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
64
+ stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
65
65
 
66
66
  To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
67
67
 
@@ -101,7 +101,7 @@ SDK functions for Image Delivery API coming soon.
101
101
 
102
102
  ## **The MIT License (MIT)**
103
103
 
104
- Copyright © 2012-2019 [Contentstack](https://www.contentstack.com). All Rights Reserved
104
+ Copyright © 2012-2020 [Contentstack](https://www.contentstack.com). All Rights Reserved
105
105
 
106
106
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
107
107
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.required_ruby_version = '>= 2.0'
13
13
 
14
14
  s.license = "MIT"
15
- s.homepage = "https://github.com/builtio-contentstack/contentstack-ruby"
15
+ s.homepage = "https://github.com/contentstack/contentstack-ruby"
16
16
 
17
17
  s.summary = %q{Contentstack Ruby client for the Content Delivery API}
18
18
  s.description = %q{Contentstack Ruby client for the Content Delivery API}
@@ -6,16 +6,16 @@ require "contentstack/region"
6
6
  require "util"
7
7
 
8
8
 
9
- # == Built.io Contentstack - Ruby SDK
10
- # Built.io Contentstack is a content management system that facilitates the process of publication by separating the content from site-related programming and design.
9
+ # == Contentstack - Ruby SDK
10
+ # Contentstack is a content management system that facilitates the process of publication by separating the content from site-related programming and design.
11
11
  # == Installation
12
12
  # gem install contentstack
13
13
  # == Initialize the Stack
14
- # @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
14
+ # @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
15
15
  # == Initialize the Stack for EU region
16
- # @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name", {"region": Contentstack::Region::EU })
16
+ # @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"region": Contentstack::Region::EU })
17
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" })
18
+ # @stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name", {"host": "https://custom-cdn.contentstack.com" })
19
19
  # == Usage
20
20
  # ==== Get single entry
21
21
  # @stack.content_type('blog').entry('<entry_uid_here>').fetch
@@ -6,11 +6,13 @@ require 'open-uri'
6
6
 
7
7
  module Contentstack
8
8
  class API
9
- def self.init_api(api_key, access_token, environment,host)
9
+ def self.init_api(api_key, delivery_token, environment,host)
10
10
  @host = host
11
11
  @api_version = '/v3'
12
12
  @environment = environment
13
- @headers = {api_key: api_key, access_token: access_token, user_agent: "ruby-sdk/#{Contentstack::VERSION}", environment: @environment}
13
+ @api_key = api_key
14
+ @access_token = delivery_token
15
+ @headers = {environment: @environment}
14
16
  end
15
17
 
16
18
  def self.fetch_content_types(uid="")
@@ -47,7 +49,11 @@ module Contentstack
47
49
  query = "?" + q.to_query
48
50
  # puts "Request URL:- #{@host}#{@api_version}#{path}#{query} \n\n"
49
51
 
50
- ActiveSupport::JSON.decode(open("#{@host}#{@api_version}#{path}#{query}").read)
52
+ ActiveSupport::JSON.decode(open("#{@host}#{@api_version}#{path}#{query}",
53
+ "api_key" => @api_key,
54
+ "access_token"=> @access_token,
55
+ "user_agent"=> "ruby-sdk/#{Contentstack::VERSION}",
56
+ "x-user-agent" => "ruby-sdk/#{Contentstack::VERSION}").read)
51
57
  end
52
58
  end
53
- end
59
+ end
@@ -5,11 +5,11 @@ require 'contentstack/asset_collection'
5
5
  module Contentstack
6
6
  class Client
7
7
  attr_reader :region, :host
8
- # Initialize "Built.io Contentstack" Client instance
9
- def initialize(api_key, access_token, environment, options={})
8
+ # Initialize "Contentstack" Client instance
9
+ def initialize(api_key, delivery_token, environment, options={})
10
10
  @region = options[:region].nil? ? Contentstack::Region::US : options[:region]
11
11
  @host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host]
12
- API.init_api(api_key, access_token, environment, @host)
12
+ API.init_api(api_key, delivery_token, environment, @host)
13
13
  end
14
14
 
15
15
 
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext'
2
+
1
3
  module Contentstack
2
4
  class Entry
3
5
  attr_reader :fields, :content_type, :uid, :owner
@@ -1,3 +1,3 @@
1
1
  module Contentstack
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -3,8 +3,8 @@ require_relative '../lib/contentstack.rb'
3
3
 
4
4
  describe Contentstack::ContentType do
5
5
  let(:client) { create_client }
6
- let(:eu_client) { create_client('ACCESS_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
7
- let(:custom_host_client) { create_client('ACCESS_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
6
+ let(:eu_client) { create_client('DELIVERY_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
7
+ let(:custom_host_client) { create_client('DELIVERY_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
8
8
 
9
9
  describe "Fetch data from API" do
10
10
  it "has class as Contentstack::ContentType" do
@@ -3,8 +3,8 @@ require_relative '../lib/contentstack.rb'
3
3
 
4
4
  describe Contentstack do
5
5
  let(:client) { create_client }
6
- let(:eu_client) { create_client('ACCESS_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
7
- let(:custom_host_client) { create_client('ACCESS_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
6
+ let(:eu_client) { create_client('DELIVERY_TOKEN_TOKEN', 'API_KEY', 'STACK_ENV', {region: Contentstack::Region::EU}) }
7
+ let(:custom_host_client) { create_client('DELIVERY_TOKEN_TOKEN', 'API_KEY', 'STACK_ENV', {host: "https://custom-cdn.contentstack.com"}) }
8
8
 
9
9
  it "has a version number" do
10
10
  expect(Contentstack::VERSION).not_to be nil
@@ -148,7 +148,7 @@ RSpec.configure do |config|
148
148
  to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + '/fixtures/category_entry.json'), :headers => {})
149
149
  end
150
150
 
151
- def create_client(access_token = ENV['ACCESS_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['STACK_ENV'], options = {})
152
- Contentstack::Client.new(access_token, api_key, environment, options)
151
+ def create_client(delivery_token = ENV['ACCESS_TOKEN'], api_key = ENV['API_KEY'], environment = ENV['STACK_ENV'], options = {})
152
+ Contentstack::Client.new(delivery_token, api_key, environment, options)
153
153
  end
154
154
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Contentstack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -76,6 +76,8 @@ files:
76
76
  - ".gitignore"
77
77
  - ".yardopts"
78
78
  - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - Gemfile.lock
79
81
  - LICENSE.txt
80
82
  - README.md
81
83
  - contentstack.gemspec
@@ -137,7 +139,7 @@ files:
137
139
  - spec/fixtures/product_entry_collection.json
138
140
  - spec/query_spec.rb
139
141
  - spec/spec_helper.rb
140
- homepage: https://github.com/builtio-contentstack/contentstack-ruby
142
+ homepage: https://github.com/contentstack/contentstack-ruby
141
143
  licenses:
142
144
  - MIT
143
145
  metadata: {}
@@ -156,8 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
158
  - !ruby/object:Gem::Version
157
159
  version: '0'
158
160
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.5.2.3
161
+ rubygems_version: 3.1.2
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Contentstack Ruby client for the Content Delivery API