api_for_asana 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c61fe2a69b0eaf817c822dff10feba5aacae6bf1cda4ebdc1d77892dfb3de758
4
+ data.tar.gz: 71c09a33604ea30b71c23a762dcd05b08898524434c3ca631606e1cda11c2e91
5
+ SHA512:
6
+ metadata.gz: cdf6598b99a950097023d3bdb577dd45a6282fa810da752c48a6c341c363c594634e8b692bb73baee7702d2916d40677b5161ad51c314ec6f5981906518dd164
7
+ data.tar.gz: 6b0c012def862bb1e26cabb7344c05881451f8b14e36ca2518e018dce35a5ba3447c0bbe69193a5060ea28c6c91848b68beb70c10ff5951f7daeb02f4a018a16
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,24 @@
1
+ require File.expand_path('lib/api_for_asana/version',__dir__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'api_for_asana'
5
+ spec.version = Version::VERSION
6
+ spec.authors = ['Melashu Amare']
7
+ spec.email = 'meshu.amare@gmail.com'
8
+ spec.license = 'MIT'
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.summary = 'This gem is an API wrapper to interact with Asana board'
11
+ spec.required_ruby_version = '>= 2.6.0'
12
+ spec.files = Dir['lib/**/*.rb', 'LICENSE', 'spec/**/*.rb', 'api_for_asana.gemspec', 'README.md', 'Gemfile']
13
+ spec.add_development_dependency 'rspec'
14
+ spec.add_development_dependency 'rspec-rails'
15
+
16
+
17
+ # spec.metadata = {
18
+ # 'rubygems_mfa_required' => 'true',
19
+ # 'documentation_uri' => 'https://github.com/melashu/json_or_ruby_to_csv',
20
+ # 'bug_tracker_uri' => 'https://github.com/melashu/json_or_ruby_to_csv/issues',
21
+ # 'homepage_uri' => 'https://rubygems.org/gems/json_or_ruby_to_csv'
22
+ # }
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ module Version
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,62 @@
1
+ require 'net/http'
2
+ module ApiForAsana
3
+
4
+ def get_sections
5
+ req = Net::HTTP::Get.new(project_url)
6
+ req['Authorization'] = token
7
+ Net::HTTP.start(project_url.hostname, project_url.port, use_ssl: true) do |http|
8
+ http.request(req)
9
+ end
10
+ end
11
+
12
+ def get_tasks(id)
13
+ uri = URI("https://app.asana.com/api/1.0/sections/#{id}/tasks")
14
+ req = Net::HTTP::Get.new(uri)
15
+ req['Authorization'] = token
16
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
17
+ http.request(req)
18
+ end
19
+ end
20
+
21
+ def update_section(id, name)
22
+ uri = section_url(id)
23
+ req = Net::HTTP::Put.new(uri)
24
+ req['Authorization'] = token
25
+ req.set_form_data(name: name)
26
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
27
+ http.request(req)
28
+ end
29
+ end
30
+
31
+ def create_section(name)
32
+ req = Net::HTTP::Post.new(project_url)
33
+ req['Authorization'] = token
34
+ req.set_form_data(name: name)
35
+ Net::HTTP.start(project_url.hostname, project_url.port, use_ssl: true) do |http|
36
+ http.request(req)
37
+ end
38
+ end
39
+
40
+ def delete_section(id)
41
+ uri = section_url(id)
42
+ req = Net::HTTP::Delete.new(uri)
43
+ req['Authorization'] = token
44
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
45
+ http.request(req)
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def project_url
52
+ URI('https://app.asana.com/api/1.0/projects/1204884610326667/sections')
53
+ end
54
+
55
+ def token
56
+ 'Bearer 1/1204884589111623:bcd5f3b78ab8580dab44dda843374ad5'
57
+ end
58
+
59
+ def section_url(id)
60
+ URI("https://app.asana.com/api/1.0/sections/#{id}")
61
+ end
62
+ end
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+
5
+ require 'spec_helper'
6
+
7
+ require 'api_for_asana'
8
+
9
+ describe 'ApiForAsana' do
10
+
11
+ let(:dummy) { Dummy.new }
12
+
13
+
14
+
15
+ context 'When we try to access all section' do
16
+
17
+ it 'should return status code 200' do
18
+
19
+ res = dummy.get_sections
20
+
21
+ expect(res.code).to eq('200')
22
+
23
+ end
24
+
25
+ end
26
+
27
+
28
+
29
+ context 'When we try to access a task list with wrong section id' do
30
+
31
+ it 'should return status code 404' do
32
+
33
+ res = dummy.get_tasks('45689')
34
+
35
+ expect(res.code).to eq('404')
36
+
37
+ end
38
+
39
+ end
40
+
41
+ context 'When we try to access a task list with correct section id' do
42
+
43
+ it 'should return status code 200' do
44
+
45
+ res = dummy.get_tasks('1204884610326670')
46
+
47
+ expect(res.code).to eq('200')
48
+
49
+ end
50
+
51
+ end
52
+
53
+ context 'When we try to update the section' do
54
+
55
+ it 'should return status code 200' do
56
+
57
+ res = dummy.update_section('1204884610326671', 'Completed')
58
+
59
+ expect(res.code).to eq('200')
60
+
61
+ end
62
+
63
+ end
64
+
65
+ context 'When we try to update the section with wrong id' do
66
+
67
+ it 'should return status code 404' do
68
+
69
+ res = dummy.update_section('12048846103271', 'Completed')
70
+
71
+ expect(res.code).to eq('404')
72
+
73
+ end
74
+
75
+ end
76
+
77
+ context 'When we try to create new section' do
78
+
79
+ it 'should return status code 201' do
80
+
81
+ res = dummy.create_section('Approved')
82
+
83
+ expect(res.code).to eq('201')
84
+
85
+ end
86
+
87
+ end
88
+
89
+ context 'When we try to delete non empty section' do
90
+
91
+ it 'should return status code 404' do
92
+
93
+ res = dummy.delete_section('12048846103271')
94
+
95
+ expect(res.code).to eq('404')
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+
104
+
105
+ class Dummy
106
+
107
+ include ApiForAsana
108
+
109
+ end
110
+
@@ -0,0 +1,98 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+ RSpec.configure do |config|
17
+ # rspec-expectations config goes here. You can use an alternate
18
+ # assertion/expectation library such as wrong or the stdlib/minitest
19
+ # assertions if you prefer.
20
+ config.expect_with :rspec do |expectations|
21
+ # This option will default to `true` in RSpec 4. It makes the `description`
22
+ # and `failure_message` of custom matchers include text for helper methods
23
+ # defined using `chain`, e.g.:
24
+ # be_bigger_than(2).and_smaller_than(4).description
25
+ # # => "be bigger than 2 and smaller than 4"
26
+ # ...rather than:
27
+ # # => "be bigger than 2"
28
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
29
+ end
30
+
31
+ # rspec-mocks config goes here. You can use an alternate test double
32
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
33
+ config.mock_with :rspec do |mocks|
34
+ # Prevents you from mocking or stubbing a method that does not exist on
35
+ # a real object. This is generally recommended, and will default to
36
+ # `true` in RSpec 4.
37
+ mocks.verify_partial_doubles = true
38
+ end
39
+
40
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
41
+ # have no way to turn it off -- the option exists only for backwards
42
+ # compatibility in RSpec 3). It causes shared context metadata to be
43
+ # inherited by the metadata hash of host groups and examples, rather than
44
+ # triggering implicit auto-inclusion in groups with matching metadata.
45
+ config.shared_context_metadata_behavior = :apply_to_host_groups
46
+
47
+ # The settings below are suggested to provide a good initial experience
48
+ # with RSpec, but feel free to customize to your heart's content.
49
+ =begin
50
+ # This allows you to limit a spec run to individual examples or groups
51
+ # you care about by tagging them with `:focus` metadata. When nothing
52
+ # is tagged with `:focus`, all examples get run. RSpec also provides
53
+ # aliases for `it`, `describe`, and `context` that include `:focus`
54
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
55
+ config.filter_run_when_matching :focus
56
+
57
+ # Allows RSpec to persist some state between runs in order to support
58
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
59
+ # you configure your source control system to ignore this file.
60
+ config.example_status_persistence_file_path = "spec/examples.txt"
61
+
62
+ # Limits the available syntax to the non-monkey patched syntax that is
63
+ # recommended. For more details, see:
64
+ # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = "doc"
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: api_for_asana
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Melashu Amare
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: meshu.amare@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - Gemfile
48
+ - api_for_asana.gemspec
49
+ - lib/api_for_asana.rb
50
+ - lib/api_for_asana/version.rb
51
+ - spec/api_for_asana_spec.rb
52
+ - spec/spec_helper.rb
53
+ homepage:
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 2.6.0
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.3.26
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: This gem is an API wrapper to interact with Asana board
76
+ test_files: []